Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to configure buildSelectQueryForIdentity()
How to configure buildSelectQueryForIdentity() [message #386590] Fri, 03 April 2009 09:16 Go to next message
Eclipse UserFriend
Hi,

I need to change behavior for JPA annotation
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

The new IDENTITY values are obtained via SELECT @@IDENTITY. But I need to
change it to SELECT SCOPE_IDENTITY().

So I made new classs

public class MySQLServerPlatform extends SQLServerPlatform {
@Override
public ValueReadQuery buildSelectQueryForIdentity() {
ValueReadQuery valueReadQuery = new ValueReadQuery("select
scope_identity()");
return valueReadQuery;
}
}

added <property name="eclipselink.target-database"
value="cz.mediaservis.metro.entity.MySQLServerPlatform"/> to
persistence.xml

and after persisting I got exception
Exception EclipseLink-4011 (Eclipse Persistence Services - 1.1.0.r3634):
org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error preallocating sequence numbers. The sequence
table information is not complete.

Probably I did something wrong. Could you plese help?
Thx
Re: How to configure buildSelectQueryForIdentity() [message #386598 is a reply to message #386590] Mon, 06 April 2009 10:12 Go to previous messageGo to next message
Eclipse UserFriend
You code looks correct. Could you include the full exception stack and
cause, and the SQL that was generated.

The error sounds like the database returned 0 or null, so also verify that
your SQL will actually return the correct value.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html
Re: How to configure buildSelectQueryForIdentity() [message #387018 is a reply to message #386598] Tue, 07 April 2009 04:57 Go to previous message
Eclipse UserFriend
Hi,

I think the problem is that INSERT statement and SELECT scope_identity()
are not in the same scope.

Pavel Zelenka
Previous Topic:java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be
Next Topic:JDBC transaction isolation?
Goto Forum:
  


Current Time: Tue Jul 01 05:37:59 EDT 2025

Powered by FUDForum. Page generated in 0.14073 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top