You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by "Hiller, Dean" <DH...@carrieraccess.com> on 2006/11/13 17:05:59 UTC

hibernate...another note

On another note, I saw some questions about hibernate on the list relating
to jaxme.  Actually, if you didn't know...... "hibernate was so popular,
they created EJB 3.0 from hibernate's example".  One suggestion for jaxme
might be to add support for putting EJB3.0 annotations on the generated
JAxME objects in which case you could then save them to a database thorugh
ANY EJB 3.0 compliant ORM including hibernate.

 

For hibernate's non-null colums, an int is fine.  Primary key is an
exception in EJB3.0 and hibernate.  In hibernate there is a kick-ass
saveOrUpdate(Object entity) method.  This method checks the primary key of
the object.  If it is null, it saves it(and generates a new primary key).
If it is non-null, it updates it.  It helps combine all saves and updates
and reduces client code significantly as it can do the same(just saw another
post in which you were asking about this).  If the primary key was not
nullable, there is no way to differentiate between a save and update except
by having two different methods in the api....update(Object
entity)....save(Object entity).  Of course, the save would overwrite the
primary key anyways as it is clearly wrong since the user would not know the
key ahead of time.

 

Later,

dean