geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale de los Reyes" <drey...@hotmail.com>
Subject Re: FindByPrimaryKey
Date Wed, 05 Apr 2006 23:14:02 GMT
Hi Olivier,

In your original post, you mentioned CarPK as your primary key object. I 
noticed this class has only a single primary key of type String (chassis, I 
think it was called). Anyway, for the entity bean that uses CarPK as the 
primary key. If possible, you can try converting it to use type String as 
the primary key. So now your findByPrimaryKey method will be using type 
String instead of CarPK.

I've gotten CMP to work in Geronimo using a simple primary key of type 
Integer, so I'm almost certain it should work for String. On the other hand, 
if your architecture requires the use of compound keys (ie. multiple columns 
needed to make a unique ID like firstname+lastname) in your other entity 
beans. You might need to use BMP, unless one of the developers give the 
official word on the correct solution. Granted, this may not answer your 
original question, but hopefully it will get you moving forward.

Personally, I had a similar situation with CMP using findByPrimaryKey with a 
primary key class. However, I was using Derby, and I was getting an 
ObjectNotFoundException.

Hopefully, others know how to get compound keys working with CMP. I still 
would like to know.

Later,
Dale

Finally, here's some code to help illustrate. Just in case...

In the home interface...
public <some object> create(CarPK carPK)....
public <some object> findByPrimaryKey(String key)....

In the implementation...
public String ejbCreate(CarPK carPK)
{
   //set stuff from carPK here...
   return null;
}

In the ejb-jar.xml...
<ejb-jar>
   <enterprise-beans>
   <entity>
   <!-- your original stuff here...->

   <prim-key-class>java.lang.String</prim-key-class>

   <!-- more of your original stuff -->
   <!-- multiple declarations of cmp-field here -->

   <primkey-field>chassis</primkey-field>
   </entity>
   </enterprise-beans>
</ejb-jar>

Your openejb-jar.xml should not have to change.


>From: "Olivier Voutat" <olivier.voutat@gmail.com>
>Reply-To: user@geronimo.apache.org
>To: user@geronimo.apache.org
>Subject: Re: FindByPrimaryKey
>Date: Wed, 5 Apr 2006 12:12:21 -0300
>
>Or even using the PostGreSQL (the sql basic syntax isn't that diferent
>neither)
>See, I'm using the console of Geronimo, and when I was creating the 
>database
>pool, I was selecting in the Database type: Other
>
>In the postgresql it is possible to change all the parameter so it connects
>to a firebird database, but doing this it will use the postgresql syntax ?
>
>Or I may saying completely stupid things right now.......
>
>Best Regards,
>Olivier Voutat
>
>On 4/5/06, Olivier Voutat <olivier.voutat@gmail.com> wrote:
> >
> > Oh Gianny,
> >
> > May that be the reason why my findByPrimaryKey and getPrimaryKey are
> > acting weird ?
> >
> > When I use the getPrimaryKey (I have ClassPK) instead of returning a
> > ClassPK object, it gives me a String object. And the findByPrimaryKey
> > doesn't work at all (data infomation in the end)
> >
> > Since the basic sql language in Firebird is the same in MS sql server,
> > could I configure it using the db-syntax-factory of it ? Just changing 
>the
> > path to the database and the driver ?
> >
> > Best Regards,
> > Olivier Voutat



Mime
View raw message