Hey,
I am trying to migrate an application from GF that uses Toplin as JPA to Jboss with Hibernate,
I'm still having a confusion of how to generate IDs as generic as possible,
Usually my app is deployed with Oracle 9/10 or Mysql DBs and I'd like to have my application be as generic as possible,
I tried just to use '@Id @GeneratedValue' annotations but with Oracle it just didn't work. so my entities ID get method looked like:
@Id @GeneratedValue //JB @Column(name="MY_ID") public Long getMyId() { return myId; }
@Id @SequenceGenerator(name="MYTABLE_GEN",sequenceName="MYTABLE_SEQ", allocationSize=1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="MYTABLE_GEN") @Column(name="MY_ID") public Long getMyId() { return myId; }
Caused by: org.hibernate.MappingException: could not instantiate id generator at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:98) at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:192) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713) ... 99 more Caused by: org.hibernate.MappingException: Dialect does not support sequences at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:595) at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:65) at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:43) at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94) ... 103 more