Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Pavel Zelenka is currently offline Pavel Zelenka
Messages: 61
Registered: July 2009
Member
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
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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


James : Wiki : Book : Blog : Twitter
Re: How to configure buildSelectQueryForIdentity() [message #387018 is a reply to message #386598] Tue, 07 April 2009 04:57 Go to previous message
Pavel Zelenka is currently offline Pavel Zelenka
Messages: 61
Registered: July 2009
Member
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: Thu Jul 31 23:49:23 EDT 2014

Powered by FUDForum. Page generated in 0.08417 seconds