Shouldn't the "@GeneratedValue" annotation declare a sequence strategy (instead of "Auto")?
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "projectid_sequence")
Which database do you use?
i am using mysql
Hmmm, after doing a bit of google I found that MySQL 5 does not support sequences at all. There are Auto Increment columns possible, but no sequence which updates it's value on each "select nextval from sequencename".
Leave the strategy to "AUTO", remove the "@SequenceGenerator" annotation and hope that Hibernate uses an appropriate default.
And activate SQL statement logging in your persistence.xml and take a look at the statements which are fired against your MySQL. Maybe they provide more info.
Hops this helps
Thanks WolfGang , i found the problem why sequence is not working. here ejb is creating tables
if i remove tables and run my application it is working fine. but now my requirement is to prevent ejb creating tables. Is there any set up to do like that.
I'm sorry but I fear I don't understand your question.
Do you mean that JBoss should not create tables on deploy? If yes: what is the property "hibernate.hbm2ddl.auto" in your "persistence.xml" set to?
The following snippet creates tables on deploy and drops them on undeploy:
<property name="hibernate.hbm2ddl.auto" value="create-drop" />