-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate tries to create same Entity/Table twice - why?
PostPosted: Wed Feb 23, 2011 2:37 pm 
Newbie

Joined: Tue Jan 11, 2011 12:35 am
Posts: 5
Hi All,
I am using hibernate with my J2EE app deployed on JBoss 6.0.
My database is Oracle 11i and Derby.
For generating primary-key (running serial Id) I use @TableGenerator annotation
in one of my Entity (PersonDTO) - like:

@Entity
@Table(name = "EDIS_PERSON")
public class PersonDTO {
@Id
@TableGenerator(name="TABLE_GEN",
table="EDIS_SEQUENCE", pkColumnName="SEQ_NAME",
valueColumnName="SEQ_COUNT",
pkColumnValue="PERSON_ID", allocationSize = 5)
@GeneratedValue(strategy=GenerationType.TABLE, generator="TABLE_GEN")
private long id;
.
.
.


And I have defined the required Entity for sequence - like:

@Entity
@Table(name = "EDIS_SEQUENCE")
public class EdmSequenceDTO {
@Id
private String SEQ_NAME;
private long SEQ_COUNT;
.
.
.

Everything works fine as far as sequence-generation is concerned.
But during the creation of entitites (when very first time I deploy my J2EE app),
I see following error in JBoss server.log file, though all my entities/tables get created successfully eventually.

14:04:16,817 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: create table EDIS_SEQUENCE ( SEQ_NAME varchar(255), SEQ_COUNT integer )
14:04:16,817 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Table/View 'EDIS_SEQUENCE' already exists in Schema 'EDM'.
14:04:16,818 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] schema update complete


I believe this is "not" actually an ERROR. It looks like since I have reference of EDIS_SEQUENCE as part of 2 Entity beans, hibernate tries to create it twice.
Firstly, when the EdmSequenceDTO is deployed and secondly, when PersonDTO refers the "EDIS_SEQUENCE" as part of @TableGenerator annotation.

In my persistence.xml file I have "hibernate.hbm2ddl.auto" property with value="update".
I need to keep this value instead of "create-drop".

I wonder is there any way I can avoid the error reported by hibernate?

Thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.