Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to dynamically specify/allocate the name of a sequence ?(EclipseLink, Sequence)
How to dynamically specify/allocate the name of a sequence ? [message #1727073] Fri, 18 March 2016 15:35 Go to next message
Celinio Fernandes is currently offline Celinio FernandesFriend
Messages: 2
Registered: February 2016
Junior Member
Hi,

How do you dynamically specify/allocate the name of a sequence to the attribute of an entity ?
My database has dozens of sequences and i need to select a specific sequence, according to the user who is connected.
Can i do that by defining a class that implements org.eclipse.persistence.config.DescriptorCustomizer ?

@Entity
 @Table(name="TOTO")
 @Customizer(mypackage.MyCustomizer.class)
 public class Toto implements Serializable {
     ...
     	@Id
	@Column(name = "Blabla")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bla_SQ")
	private long idblabla;
...
 }





If someone has already done that, i would be interested to take a look at the code.

Thanks in advance for helping.
Re: How to dynamically specify/allocate the name of a sequence ? [message #1727248 is a reply to message #1727073] Mon, 21 March 2016 14:44 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I'm not sure how something like that would work - two or more users of the same application using different sequence numbers to insert in the same table will lead to sequence conflicts, won't it? Unless you are talking about multi tenancy, I'm not quite sure what the reasoning is.

That said, you might want to implement your own sequence generator class that can perform what ever logic you need. See https://wiki.eclipse.org/EclipseLink/Examples/JPA/CustomSequencing for an example of how to set one up.
Re: How to dynamically specify/allocate the name of a sequence ? [message #1727254 is a reply to message #1727248] Mon, 21 March 2016 15:41 Go to previous message
Celinio Fernandes is currently offline Celinio FernandesFriend
Messages: 2
Registered: February 2016
Junior Member
Thanks for your reply.
I will check your link about the sequence generator class.

Regarding your question, i should have mentioned that the application is deployed on several servers and, depending on the user, connects to a specific database.
So, one single application but multiple databases. And of course the same sequence is always used in a database.
Previous Topic:java.lang.RuntimeException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v2011
Next Topic:Questions re eclipselink versions, oracle 12c, xmltype etc
Goto Forum:
  


Current Time: Tue Apr 16 16:36:13 GMT 2024

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

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

Back to the top