TableGenerator - Sequence/ID Generation [message #1174837] |
Thu, 07 November 2013 10:43 |
Babji Chetty 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:
@Entity
@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;
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "test_gen")
@Column(name = "NWTID", nullable = false, updatable = false)
@Override
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">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>TESTDS</jta-data-source>
<properties>
<property name="eclipselink.target-database" 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="eclipselink.id-validation" 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"/>
</properties>
</persistence-unit>
Do you have any clue, as to what's happening here?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03320 seconds