users@glassfish.java.net

RE: RE: Re: TLE vs Hibernate

From: Jason Lee <lee_at_iecokc.com>
Date: Fri, 16 Mar 2007 14:07:51 -0500

Bah! Wrong list. Sorry... hehe

-----
Jason Lee, SCJP
Senior Software Engineer
http://www.iec-okc.com
 

> -----Original Message-----
> From: Jason Lee
> Sent: Friday, March 16, 2007 2:04 PM
> To: users_at_glassfish.dev.java.net; dev_at_javaserverfaces.dev.java.net
> Subject: RE: Re: TLE vs Hibernate
>
> If I specify sequenceName in the annotation (as per the
> spec), why is TopLink creating its own value for that? I've
> worked around the issue for now by changing the sequence name
> to match what TL is generating and adding a default value to
> the field in the DB, but I would have thought that logic
> would go like this:
>
> 1) Check for supplied sequence name, and generate on if necessary
> 2) Assign sequence's next value to property
> 3) Persist object
>
> Right now, it seems to be doing
> 1) Persist object
> 2) Generate sequence name
> 3) Get current value of sequence
> 4) Update the object property with value
>
> Which I guess makes sense, as that allows sequences and
> indentities to be handled in the same way, if not with
> largely the same code, but it also puts a burden on the
> database that other providers (notably,
> Hibernate) do not, and I'm guessing the spec is silent there.
> Either that, or one of the implementations is non-compliant.
> However, since PostgreSQL does not support identity fields
> (that I've seen), it seems odd to force that behavior on it,
> and TLE *does* know what DB it's on:
>
> <property name="toplink.target-database" value="PostgreSQL"/>
>
> So, do we just modify our apps to work around this? Is there
> anything you need/want from me?
>
> Thanks! :)
>
> -----
> Jason Lee, SCJP
> Senior Software Engineer
> http://www.iec-okc.com
>
>
> > -----Original Message-----
> > From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
> > Sent: Friday, March 16, 2007 1:41 PM
> > To: users_at_glassfish.dev.java.net
> > Subject: Re: TLE vs Hibernate
> >
> > I think you are hitting the problem that TopLink can't
> support 2 types
> > of identity - sequence and identity on the same database
> type, so it
> > chooses 1 that it can support without any warning.
> >
> > 'engineers_ID_seq' is the expected name (constructed out of
> entity and
> > field
> > name) prior to the fix for issue 283, so it's strange that
> you still
> > see this behavior.
> >
> > regards,
> > -marina
> >
> > Jason Lee wrote:
> > > I upgraded this morning to the b40 nightly for 3/16.
> When I try to
> > > add a record, I got the null value exception, so I added
> > > "nextval('engineers_seq')" as the default value to the PK
> > field. That
> > > solved the insert issue, but it appears the TopLink is
> > trying to read
> > > the sequence value back out, getting me this odd error:
> > >
> > > Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build
> > > b40-rc
> > > (03/15/2007))):
> > oracle.toplink.essentials.exceptions.DatabaseException
> > > Internal Exception: org.postgresql.util.PSQLException:
> > ERROR: relation
> > > "engineers_id_seq" does not existError Code: 0 Call:select
> > > currval('engineers_ID_seq')
> > >
> > > Confusing, as I specify the generator with:
> > >
> > > @SequenceGenerator(name = "ENGINEERS_SEQ", allocationSize = 1,
> > > sequenceName = "engineers_seq")
> > >
> > > What am I missing? :|
> > >
> > > -----
> > > Jason Lee, SCJP
> > > Senior Software Engineer
> > > http://www.iec-okc.com
> > >
> > >
> > >
> > >>-----Original Message-----
> > >>From: Jason Lee
> > >>Sent: Friday, March 16, 2007 8:46 AM
> > >>To: users_at_glassfish.dev.java.net
> > >>Subject: RE: Re: TLE vs Hibernate
> > >>
> > >>In my testing, I'm using Sun Java System Application Server
> > >>9.1 (build b38-rc). In production, though, we're still on
> > v1 ur1 p01.
> > >>
> > >>-----
> > >>Jason Lee, SCJP
> > >>Senior Software Engineer
> > >>http://www.iec-okc.com
> > >>
> > >>
> > >>
> > >>>-----Original Message-----
> > >>>From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
> > >>>Sent: Thursday, March 15, 2007 5:55 PM
> > >>>To: users_at_glassfish.dev.java.net
> > >>>Subject: Re: TLE vs Hibernate
> > >>>
> > >>>Jason,
> > >>>
> > >>>Are you using the latest v2 build?
> > >>>
> > >>>thanks,
> > >>>-marina
> > >>>
> > >>>Jason Lee wrote:
> > >>>
> > >>>>In all of our apps, we are currently using Hibernate as the JPA
> > >>>>provider due to what we (read as, I) understood to be a
> > >>
> > >>bug in TLE
> > >>
> > >>>>with regard to SequenceGenerators and PostgreSQL. I'd
> > >>>
> > >>>really like to
> > >>>
> > >>>>use TLE, as I'm not a big fan of the extra
> configuration step in
> > >>>>setting up our applications, nor am I, as our de facto
> GlassFish
> > >>>>admin, a big fan of the extra installation step of adding
> > >>>
> > >>>the Hibernate jars to the server.
> > >>>
> > >>>>Those are two points of failure I'd like to avoid. To
> > >>
> > >>that end, I
> > >>
> > >>>>started testing an app of mine using TLE and hit a snag.
> > >>>
> > >>>Here's part
> > >>>
> > >>>>of my entity POJO:
> > >>>>
> > >>>>@Entity
> > >>>>@Table(name = "engineers")
> > >>>>@SequenceGenerator(name = "ENGINEERS_SEQ", allocationSize = 1,
> > >>>>sequenceName = "engineers_seq") public class Engineer
> implements
> > >>>>Serializable {
> > >>>> @Id
> > >>>> @GeneratedValue(strategy = GenerationType.SEQUENCE,
> > >>
> > >>generator =
> > >>
> > >>>>"ENGINEERS_SEQ")
> > >>>> protected Integer id;
> > >>>>With Hibernate, when I would create a new Engineer
> > >>
> > >>object, i could
> > >>
> > >>>>just call entityManager.persist(engineer) and be done with
> > >>>
> > >>>it. When
> > >>>
> > >>>>switch to TLE, the database barks because the ID has not
> > >>
> > >>been set.
> > >>
> > >>>>Short of changing the tables to have a default value of
> > >>>>nextval($SEQ_NAME), how do I approach this using TLE?
> > >>>>
> > >>>>I even tried this:
> > >>>>
> > >>>> @Id
> > >>>> @SequenceGenerator(name = "ENGINEERS_SEQ",
> > >>
> > >>allocationSize = 1,
> > >>
> > >>>>sequenceName = "engineers_seq")
> > >>>> @GeneratedValue(strategy = GenerationType.SEQUENCE,
> > >>
> > >>generator =
> > >>
> > >>>>"ENGINEERS_SEQ")
> > >>>> @Column
> > >>>> protected Integer id;
> > >>>>based on the documentation here
> > >>>>
> > >>>
> > >>http://www.oracle.com/technology/products/ias/toplink/jpa/re
> > sources/to
> > >>
> > >>>>plink-jpa-annotations.html#SequenceGenerator with no love. :)
> > >>>>
> > >>>>-----
> > >>>>Jason Lee, SCJP
> > >>>>Senior Software Engineer
> > >>>>http://www.iec-okc.com <http://www.iec-okc.com/>
> > >>>>
> > >>>
> > >>>
> > >>------------------------------------------------------------
> > ---------
> > >>
> > >>>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > >>>For additional commands, e-mail:
> users-help_at_glassfish.dev.java.net
> > >>>
> > >>>
> > >>
> > >>------------------------------------------------------------
> > ---------
> > >>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > >>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> > >>
> > >>
> > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>