Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » TableGenerator - Sequence/ID Generation(TableGenerator Id Generation With Custom Table)
TableGenerator - Sequence/ID Generation [message #1174837] Thu, 07 November 2013 10:43 Go to next message
Babji Chetty is currently offline Babji ChettyFriend
Messages: 2
Registered: November 2013
Junior Member
I'm working on a JAVAEE Enterprise application, which has the technology stack: Glassfish 3.1, EJB 3.1, EclipseLink 2.4.2, SQL Server 2008 R2. In the EJB module, I have a couple of entities which use SequenceGenerator's and a couple of entities with TableGenerator's.

The SequenceGenerator's are working fine, but the TableGenerator's aren't. I tried to check the server.log by setting the EclipseLink's logging to '**FINEST**', but I don't see any queries logged for getting the next value of the Id. The EJB entity that uses TableGenerator is as below:

    @Table(name = "TEST")
    @TableGenerator(name = "test_gen", table = "ID_GENERATOR", pkColumnName = "ID_NAME", pkColumnValue = "TEST", valueColumnName = "ID_VAL", allocationSize = 50, initialValue = 1)
    public class Test extends SuperClass implements Interface1, Interface2, Interface3, Interface4, Interface5, Serializable {
        private static final long serialVersionUID = 5084413459400887388L;
        /** The id of the entry.
        protected long id = 0;
        @GeneratedValue(strategy = GenerationType.TABLE, generator = "test_gen")
        @Column(name = "NWTID", nullable = false, updatable = false)
        public long getId() {
            return id;

**Note**: The Table 'ID_GENERATOR' is used by all entities with TableGenerator annotation, with a Unique Generator name.

After checking the logs with '**FINEST**' setting, I tried many other ways, but couldn't get the 'TableGenerator' working. Later, I downloaded the EclipseLink's (2.4.2) sources and debugged the 'Sequencing' mechanism, during deployment, as well as at application runtime. During deployment, I found the Sequence 'TEST' to be initialized, but at runtime, the Id's are not being generated.

BTW, my persistence.xml has a couple of datasources, with the following properties for EclipseLink:

<persistence-unit name="TestCtx" transaction-type="JTA">
                <property name=""  value="SQLServer"/>
                <property name="eclipselink.query-results-cache" value="false"/>
                <property name="eclipselink.cache.shared.default" value="false"/>            
                <property name="eclipselink.weaving" value="static"/>
                <property name="" value="NULL"/>
                <property name="javax.persistence.validation.mode" value="NONE"/>
                <property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
                <property name="eclipselink.logging.thread" value="false"/>
                <property name="eclipselink.logging.session" value="false"/>
                <property name="eclipselink.logging.timestamp" value="false"/>
                <property name="eclipselink.logging.exceptions" value="false"/>

Do you have any clue, as to what's happening here?
Re: TableGenerator - Sequence/ID Generation [message #1181283 is a reply to message #1174837] Mon, 11 November 2013 13:58 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1353
Registered: July 2009
Senior Member
This looks like a cross post of

if so, then the issue was with using the "eclipselink.allow-zero-id" property to allow 0 to be used as an ID instead of having them generated.
Re: TableGenerator - Sequence/ID Generation [message #1187885 is a reply to message #1181283] Fri, 15 November 2013 10:30 Go to previous message
Babji Chetty is currently offline Babji ChettyFriend
Messages: 2
Registered: November 2013
Junior Member
Chris: Thanks for posting it. As explained in that cross post, the 2 EclipseLink's pesistence.xml properties disable the sequence generation for TableGenerator's. There's no proper documentation, as to why this is like that...but trying different test cases, I have found the solution to my problem.
Previous Topic:EclipseLink & Websphere cluster & Oracle 11g2 DCN
Next Topic:javax.naming.NoInitialContextException with DatabaseSession
Goto Forum:

Current Time: Mon May 25 22:19:36 GMT 2020

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

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

Back to the top