Discussion:
[Middlegen-user] CMR/CMP Problem
Leslie Hughes
2004-08-17 00:26:08 UTC
Permalink
Hi,

I'm getting a CMR/CMP problem when I try to call create with a VO instance.

In the Middlegen generated ejbCreate method (which takes a VO as a param)
the generated code is calling a setter on a CMP field that holds the FK.In
other words, instead of setting the relationship in the ejbPostCreate via a
Local to the other bean, it's trying to set the (integer) FK directly with
something like setFoo(vo.getFoo()). This causes Weblogic to complain at
runtime.

If I set FKCMP="false" then I get compilation errors - the same copy from VO
create code is generated and setters are being called but of course, the
setter itself isnt generated.

If I comment out the setters everything works just fine.

So I guess this is a bug in Middlegen - it shouldn't be generating VO fields
for CMR fields maybe?


Bye

Les
Eivind Waaler
2004-08-17 04:59:01 UTC
Permalink
Post by Leslie Hughes
Hi,
I'm getting a CMR/CMP problem when I try to call create with a VO instance.
In the Middlegen generated ejbCreate method (which takes a VO as a param)
the generated code is calling a setter on a CMP field that holds the FK.In
other words, instead of setting the relationship in the ejbPostCreate via a
Local to the other bean, it's trying to set the (integer) FK directly with
something like setFoo(vo.getFoo()). This causes Weblogic to complain at
runtime.
If I set FKCMP="false" then I get compilation errors - the same copy from VO
create code is generated and setters are being called but of course, the
setter itself isnt generated.
If I comment out the setters everything works just fine.
So I guess this is a bug in Middlegen - it shouldn't be generating VO fields
for CMR fields maybe?
Yes that sounds like a bug with Middlegen. It's been a long time since I
looked at the VO stuff, but I'll try to get it fixed in the next release
(hopefully quite soon). As always, if people submit patches or sample code
it's faster for me to implement :)

Cheers
.eivind
Post by Leslie Hughes
Bye
Les
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Wouter Boers
2004-08-22 14:23:01 UTC
Permalink
It's more a bug with the template.

The same goes for using oracle keys in combination with weblogic.

I have made some modifications to the cmp20 template which suits out needs
and may be of interest for general usage. But since they are pretty
environment specific they will probably not apply to everyone.

If interested I can send interested parties a copy of my template.

Regards, Wouter
Post by Eivind Waaler
Post by Leslie Hughes
Hi,
I'm getting a CMR/CMP problem when I try to call create with a VO instance.
In the Middlegen generated ejbCreate method (which takes a VO as a param)
the generated code is calling a setter on a CMP field that holds the FK.In
other words, instead of setting the relationship in the ejbPostCreate via a
Local to the other bean, it's trying to set the (integer) FK directly with
something like setFoo(vo.getFoo()). This causes Weblogic to complain at
runtime.
If I set FKCMP="false" then I get compilation errors - the same copy from VO
create code is generated and setters are being called but of course, the
setter itself isnt generated.
If I comment out the setters everything works just fine.
So I guess this is a bug in Middlegen - it shouldn't be generating VO fields
for CMR fields maybe?
Yes that sounds like a bug with Middlegen. It's been a long time since I
looked at the VO stuff, but I'll try to get it fixed in the next release
(hopefully quite soon). As always, if people submit patches or sample code
it's faster for me to implement :)
Cheers
.eivind
Post by Leslie Hughes
Bye
Les
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Met vriendelijk groet, Wouter Boers

M.-Leander Reimer
2004-08-17 05:32:02 UTC
Permalink
Hi Leslie,

had the same problem under JBOss. Basically the problem is in the setVO
methods of the CMP classes generated by XDoclet where the CMR fields of
the entity are modified which is not allowed when you are creating an
entity. You can always use the light value objects and set any FKs in
there to create an entity (works under JBoss).

I guess the ejbCreate(VO) methods should be removed from the Middlegen
template all together since they'll never work as far as I can tell.

Leander
Post by Leslie Hughes
Hi,
I'm getting a CMR/CMP problem when I try to call create with a VO instance.
In the Middlegen generated ejbCreate method (which takes a VO as a param)
the generated code is calling a setter on a CMP field that holds the FK.In
other words, instead of setting the relationship in the ejbPostCreate via a
Local to the other bean, it's trying to set the (integer) FK directly with
something like setFoo(vo.getFoo()). This causes Weblogic to complain at
runtime.
If I set FKCMP="false" then I get compilation errors - the same copy from VO
create code is generated and setters are being called but of course, the
setter itself isnt generated.
If I comment out the setters everything works just fine.
So I guess this is a bug in Middlegen - it shouldn't be generating VO fields
for CMR fields maybe?
Bye
Les
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Darren Hartford
2004-08-17 22:27:14 UTC
Permalink
I have had similar issues and solutions to the CMR problem generated by the VO's, but I still rather make that small change than throw-out the VO code in Middlegen - it IS a huge timesaver and a core part of the at least the projects I work on. I understand a lot of the devs are working/waiting/working on Middlegen3 based on the new framework(s), and not a lot of time has gone into the VO code since its original release, but I still appreciate what is there and just needs to be cleaned up a bit.
-----Original Message-----
Sent: Tuesday, August 17, 2004 3:26 AM
Subject: Re: [Middlegen-user] CMR/CMP Problem
Hi Leslie,
had the same problem under JBOss. Basically the problem is in
the setVO
methods of the CMP classes generated by XDoclet where the CMR
fields of
the entity are modified which is not allowed when you are creating an
entity. You can always use the light value objects and set any FKs in
there to create an entity (works under JBoss).
I guess the ejbCreate(VO) methods should be removed from the
Middlegen
template all together since they'll never work as far as I can tell.
Leander
Post by Leslie Hughes
Hi,
I'm getting a CMR/CMP problem when I try to call create
with a VO instance.
Post by Leslie Hughes
In the Middlegen generated ejbCreate method (which takes a
VO as a param)
Post by Leslie Hughes
the generated code is calling a setter on a CMP field that
holds the FK.In
Post by Leslie Hughes
other words, instead of setting the relationship in the
ejbPostCreate via a
Post by Leslie Hughes
Local to the other bean, it's trying to set the (integer)
FK directly with
Post by Leslie Hughes
something like setFoo(vo.getFoo()). This causes Weblogic
to complain at
Post by Leslie Hughes
runtime.
If I set FKCMP="false" then I get compilation errors - the
same copy from VO
Post by Leslie Hughes
create code is generated and setters are being called but
of course, the
Post by Leslie Hughes
setter itself isnt generated.
If I comment out the setters everything works just fine.
So I guess this is a bug in Middlegen - it shouldn't be
generating VO fields
Post by Leslie Hughes
for CMR fields maybe?
Bye
Les
M.-Leander Reimer
2004-08-18 09:35:01 UTC
Permalink
My fault, I just had a look at the current middlegen template in CVS and
there are not ejbCreates with a value object parameter anyway, only the
once with a LightVO as parameter. So nothing should be removed :-) and
everythings works fine :-)

Different question: I am using Middlegen and Maven 1.0 (+ Middlegen
Plugin) and I am using a fileproducer with id=entity-cmp-20 to register
a custom template for the cmp20 plugin.
Darren Hartford
2004-08-18 10:35:36 UTC
Permalink
Hi Leander,
Also running a Maven, but I've had better success without the plugin, and rather approach it similar to an Ant task in the maven.xml file. Maybe see if the problem still occurs outside the plugin so at least eliminate that as a culprit?

example maven.xml goal, modify to your heart's desire:
<goal name="middlegen">
<taskdef name="middlegen" classname="middlegen.MiddlegenTask">
<classpath>
<path refid="maven.dependency.classpath"/>
</classpath>
</taskdef>

<middlegen
appname="${pom.artifactId}"
prefsdir="${basedir}"
gui="false"
databaseurl="jdbc:blah://blah/blah"
driver="com.blah.Driver"
username="user"
password="pass"
<cmp20
destination="${basedir}/generated/middlegen"
mergedir="${basedir}/src/conf/middlegen"
package="${pom.package}.domain.ejb"
interfacepackage="${pom.package}.domain.interfaces"
pkclass="false"
dataobject="false"
valueobject="true"
viewtype="local"
readonly="false"
fkcmp="true"
guid="false"
sessionfacade="false"
<jboss/>
</cmp20>
<!--
<hibernate
destination="${basedir}/generated/hibernate"
package="${pom.package}.hibernate"
genXDocletTags="true"
genIntergratedCompositeKeys="false"
/>
-->
/>
</middlegen>
</goal>
=========
-D
-----Original Message-----
Sent: Wednesday, August 18, 2004 7:35 AM
Subject: Re: [Middlegen-user] CMR/CMP Problem --> And
Different Question
My fault, I just had a look at the current middlegen template
in CVS and
there are not ejbCreates with a value object parameter
anyway, only the
once with a LightVO as parameter. So nothing should be
removed :-) and
everythings works fine :-)
Different question: I am using Middlegen and Maven 1.0 (+ Middlegen
Plugin) and I am using a fileproducer with id=entity-cmp-20
to register
a custom template for the cmp20 plugin.
Loading...