[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] How to use QuerySequence of eclipselink
|
QuerySequence is a base class for TableSequence and NativeSequence - classes
used to support JPA TableGenarator and SequenceGenerator/Identity.
To define customized database sequence I would first look at overriding
NativeSequence (not QuerySequence).
To assign custom sequence to entity I would use SequenceGenerator.
@Entity
public class Address {
...
@GeneratedValue(generator="ADDRESS_SEQ")
@SequenceGenerator(name="ADDRESS_SEQ", allocationSize=25)
@Column(name="ADDRESS_ID")
public int getId() {
return id;
}
...
}
Then in SessionCustomizer substitute the original sequence for the customary
one:
public class MyCustomizer implements SessionCustomizer {
public void customize(Session session) {
Sequence originalSequence =
session.getPlatform().getSequence("ADDRESS_SEQ");
session.getPlatform().addSequence(MySequence("ADDRESS_SEQ",
originalSequence.getPreallocationSize()));
}
MyCustomizer class should be packed with the rest of the persistence unit
(into the same jar with entity classes)
and should be listed in the properties in persistence.xml (or properies
passed to createEntityManagerFactory):
<properties>
...
<property name="eclipselink.session.customizer"
value="MyCustomizer"/>
</properties>
----- Original Message -----
From: "Manupriya" <manupriya.sinha@xxxxxxxxx>
To: <eclipselink-users@xxxxxxxxxxx>
Sent: Wednesday, August 12, 2009 5:50 AM
Subject: [eclipselink-users] How to use QuerySequence of eclipselink
Hi,
I am trying to use QuerySequence class to create customized generator
using
database sequence.
We I am trying to add it in persistence.xml I am getting
ClassNotFoundExcetion.
Can anyone tell me how to use QuerySequence?
Regards,
--
View this message in context:
http://www.nabble.com/How-to-use-QuerySequence-of-eclipselink-tp24931901p24931901.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users