Immo Heikkinen wrote:
You are not using the table generator you have defined. You need to add the generator name:
Code:
@GeneratedValue(strategy=GenerationType.TABLE,generator="TBMPTYPE")
Thanks for the answer, I was lead to error by a manual that didn't state that in the example.
The example they gave was:
@TableGenerator(name="Emp_Gen")
@Id @GeneratedValue(generator="Emp_Gen")
private int id;
Now I'm having another trouble ... it does update the generator table correctly, but it still does not persist data on the TBMPTYPE ...
The code:
System.out.println(">>> execute");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("MPService");
EntityManager em = emf.createEntityManager();
Type type = new Type();
type.setDescription("First Description");
em.persist(type);
System.out.println("<<< execute");
Should be able to persist, still it doesn't do anything.
Any idea I should search for?
My logs:
...
16:15:18,968 DEBUG org.hibernate.impl.SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
16:15:18,968 DEBUG org.hibernate.impl.SessionFactoryObjectFactory:76 - registered: 2c9285c215ec8bb00115ec8bb1b80000 (unnamed)
16:15:18,968 INFO org.hibernate.impl.SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
16:15:18,968 DEBUG org.hibernate.impl.SessionFactoryImpl:308 - instantiated session factory
16:15:18,968 DEBUG org.hibernate.impl.SessionFactoryImpl:392 - Checking 0 named HQL queries
16:15:18,968 DEBUG org.hibernate.impl.SessionFactoryImpl:412 - Checking 0 named SQL queries
16:15:19,031 DEBUG org.hibernate.impl.SessionImpl:220 - opened session at timestamp: 11936745189
16:15:19,031 DEBUG org.hibernate.event.def.AbstractSaveEventListener:514 - transient instance of: com.mp.persistence.entity.Type
16:15:19,031 DEBUG org.hibernate.event.def.DefaultPersistEventListener:124 - saving transient instance
16:15:19,031 DEBUG org.hibernate.jdbc.AbstractBatcher:556 - opening JDBC connection
16:15:19,031 DEBUG org.hibernate.connection.DriverManagerConnectionProvider:93 - total checked-out connections: 0
16:15:19,031 DEBUG org.hibernate.connection.DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
16:15:19,031 DEBUG org.hibernate.SQL:132 - select KGEN_KVAL from TBMPKGEN where KGEN_KTBL = 'TBMPTYPE' for update
16:15:19,046 DEBUG org.hibernate.jdbc.AbstractBatcher:571 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
16:15:19,062 DEBUG org.hibernate.connection.DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
16:15:19,062 DEBUG org.hibernate.id.MultipleHiLoPerTableGenerator:194 - new hi value: 9
16:15:19,062 DEBUG org.hibernate.event.def.AbstractSaveEventListener:112 - generated identifier: 450, using strategy: org.hibernate.id.MultipleHiLoPerTableGenerator
16:15:19,062 DEBUG org.hibernate.event.def.AbstractSaveEventListener:153 - saving [com.mp.persistence.entity.Type#450]
Any help appreciated.
Thanks.