Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to configure buildSelectQueryForIdentity()
https://www.eclipse.org/forums/index.php/mv/msg/125986/386590/#msg_386590
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]]>Pavel Zelenka2009-04-03T13:16:23-00:00Re: How to configure buildSelectQueryForIdentity()
https://www.eclipse.org/forums/index.php/mv/msg/125986/386598/#msg_386598
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 Sutherland2009-04-06T14:12:28-00:00Re: How to configure buildSelectQueryForIdentity()
https://www.eclipse.org/forums/index.php/mv/msg/125986/387018/#msg_387018
I think the problem is that INSERT statement and SELECT scope_identity()
are not in the same scope.
Pavel Zelenka]]>Pavel Zelenka2009-04-07T08:57:03-00:00