-->
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.  [ 2 posts ] 
Author Message
 Post subject: entity class has changed but kept is name =>null primary key
PostPosted: Wed Jan 19, 2011 11:16 am 
Beginner
Beginner

Joined: Mon Jan 04, 2010 2:52 pm
Posts: 30
hello,

I get this exception:

Code:
org.hibernate.exception.ConstraintViolationException: could not insert: [de.bhc.pepa.Report]
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
  [...]
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: ID table: REPORTS in statement [insert into reports (id, dirname, project_id, zaehler) values (null, ?, ?, ?)]
   at org.hsqldb.jdbc.Util.throwError(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
   at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:57)
   ... 38 more


for this class:

Code:
@Entity
@Table(name="reports")
public class Report implements ToolTipProvider, Modifiable{
   @Id
   @GeneratedValue
   protected Long id;
   @Column
   private Integer zaehler;
[...]


This only happens in old Databases which contained an old (and completely
different) version of "Report" (same name!). I checked that these older
Databases do not have any Report-Instances, and the list of fields from the
new "Report" habe been appended to the list of fields in the old "reports"
table:

Code:
Reports:
  ID
  CREATION_DATE
  DESCRIPTION
  MODIFICATION_DATE
  NAME
  OWNER
  _PROJECT_ID
  // following are the new fields:
  DIRNAME
  ZAEHLER
  PROJECT_ID


Is there a way to fix this other than renaming the new "Report" class?
Can we make hibernate forget about these old classes?

Thanks a lot in advance!


Top
 Profile  
 
 Post subject: Re: entity class has changed but kept is name =>null primary key
PostPosted: Thu Jan 20, 2011 9:41 am 
Beginner
Beginner

Joined: Mon Jan 04, 2010 2:52 pm
Posts: 30
=> the best solution I found is to rename to table, which is less painful than
renaming the Entity.

However, you still have old tables lying around in the databases.


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

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.