Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Getting Trigger-Generated ID

I believe this problem is fixed in 2.3.2, which will be released soon.
There is 2.3.2 RC1 milestone available (that has the fix):
http://www.eclipse.org/eclipselink/downloads/milestones.php
On 12/7/2011 9:47 PM, Jorge Arrieta wrote:
Hey,

I'm trying to get back the id generated for an entity by a before insert
trigger.

I've annotated the field like so:

@Id
@Column(nullable=false)
@ReturnInsert(returnOnly=true)
private Integer id;

and the sql is being generated correctly:

21:47:21.515 [Component Resolve Thread] DEBUG
v.e.l.e.r.model.CustomSessionLogger - INSERT INTO public.test (DES)
VALUES (?) RETURNING ID
	bind =>  [blah]

but after doing an em.persist(obj) and committing the id is still
null...

p.s.: I'm using eclipselink 2.3.1.v20110908-r10021, and PostgreSQL
9.1.1, on 32bit linux if it's at all relevant.
p.p.s.: I could just get the id by putting the trigger function's logic
in another procedure (doing it in java is not an option) and calling it
before-hand (wrapping it all on a transaction), but this should be
working...


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top