-->
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.  [ 4 posts ] 
Author Message
 Post subject: Unable to delete entity graph; null FK constraints checks
PostPosted: Wed Feb 08, 2006 9:40 am 
Newbie

Joined: Wed Feb 08, 2006 8:48 am
Posts: 6
When deleting entity 'match', Hibernate tries to update not-null property 'winner' of MatchSet, instead of just deleting this entity.
This results in a foreign key violation, because 'winner' cannot be null.

Is this

@ManyToOne(optional = false)
public Player getWinner() {
return winner;
}

wrongly definied?

Hibernate version:
hibernate-3.1.2
hibernate-annotations-3.1beta8

Data model:

Code:
@Entity
public class Player extends Persistent implements Comparable {
   private String   firstName;
   private String   lastName;

   public Player() {
      super();
   }

   public Player( String firstName, String lastName ) {
      this.firstName = firstName;
      this.lastName = lastName;
   }

   @NotNull
   public String getFirstName() {
      return firstName;
   }

   public void setFirstName( String firstName ) {
      this.firstName = firstName;
   }

   @NotNull
   public String getLastName() {
      return lastName;
   }

   public void setLastName( String lastName ) {
      this.lastName = lastName;
   }
}

@Entity
@Table(name = "SquashMatch")
public class Match extends Persistent {
   private List<MatchSet>      sets   = new LinkedList<MatchSet>();

   public Match() {
   }

   @OneToMany(cascade = { CascadeType.ALL })
   @JoinColumn(name = "squashMatch")
   @IndexColumn(name = "idx")
   @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
   public List<MatchSet> getSets() {
      return sets;
   }

   public void setSets( List<MatchSet> sets ) {
      this.sets = sets;
   }
}

@Entity
@Table(name = "MatchSet")
public class MatchSet extends Persistent {
   private Player            winner;

   public MatchSet() {
   }

   public MatchSet( Player winner ) {
      this.winner = winner;
   }

   @ManyToOne(optional = false)
   public Player getWinner() {
      return winner;
   }

   public void setWinner( Player winner ) {
      this.winner = winner;
   }
}


Executed piece of code:
Code:
Match match = matchDao.findById( new java.lang.Long( 1 ) );
matchDao.makeTransient( match );

where

public void makeTransient( T entity ) {
   getHibernateTemplate().delete( entity );
}



Full stack trace of any exception that occurs:
INFO (2006-02-08) 14:17.36:890 [com.mobilebox.squasher.test.MatchServiceTestCase] Loading config for: applicationContext.xml
INFO (2006-02-08) 14:17.37:000 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [applicationContext.xml]
INFO (2006-02-08) 14:17.37:531 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=2864404]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,placeholderConfig,transactionInterceptor,org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor,org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator,baseHibernateDao,groupDao,leagueDao,roundDao,scheduleDao,seasonDao,matchDao,playerDao,roleDao,userDao,imageDao,newsDao,leagueService,matchService,userService,imageService,newsService,txtResultsImporterService,sampleValueList]; root of BeanFactory hierarchy
INFO (2006-02-08) 14:17.37:562 [org.springframework.context.support.ClassPathXmlApplicationContext] 26 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=2864404]
INFO (2006-02-08) 14:17.37:640 [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] Loading properties file from class path resource [spring.properties]
INFO (2006-02-08) 14:17.37:656 [org.springframework.core.CollectionFactory] JDK 1.4+ collections available
INFO (2006-02-08) 14:17.37:687 [org.springframework.core.CollectionFactory] Commons Collections 3.x available
INFO (2006-02-08) 14:17.37:859 [org.springframework.aop.framework.DefaultAopProxyFactory] CGLIB2 available: proxyTargetClass feature enabled
INFO (2006-02-08) 14:17.38:015 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'org.hibernate.cfg.DefaultComponentSafeNamingStrategy#1bb60c3' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.38:031 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'dataSource' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.38:484 [org.springframework.orm.hibernate3.LocalSessionFactoryBean] Building new Hibernate SessionFactory
INFO (2006-02-08) 14:17.41:125 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'sessionFactory' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:140 [org.springframework.orm.hibernate3.HibernateTransactionManager] Using DataSource [org.apache.commons.dbcp.BasicDataSource@1d27069] of Hibernate SessionFactory for HibernateTransactionManager
INFO (2006-02-08) 14:17.41:140 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'transactionManager' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:140 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#1afae45' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:140 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'transactionInterceptor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:156 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:156 [org.springframework.context.support.ClassPathXmlApplicationContext] Bean 'org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO (2006-02-08) 14:17.41:156 [org.springframework.context.support.ClassPathXmlApplicationContext] Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@1304043]
INFO (2006-02-08) 14:17.41:156 [org.springframework.context.support.ClassPathXmlApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@234265]
INFO (2006-02-08) 14:17.41:156 [org.springframework.beans.factory.support.DefaultListableBeanFactory] Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,placeholderConfig,transactionInterceptor,org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor,org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator,baseHibernateDao,groupDao,leagueDao,roundDao,scheduleDao,seasonDao,matchDao,playerDao,roleDao,userDao,imageDao,newsDao,leagueService,matchService,userService,imageService,newsService,txtResultsImporterService,sampleValueList]; root of BeanFactory hierarchy]
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Found 3 fields on class com.mobilebox.squasher.test.MatchServiceTestCase
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected com.mobilebox.squasher.service.MatchService com.mobilebox.squasher.test.MatchServiceTestCase.matchService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'matchService'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected com.mobilebox.squasher.service.UserService com.mobilebox.squasher.test.MatchServiceTestCase.userService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'userService'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected com.mobilebox.squasher.service.LeagueService com.mobilebox.squasher.test.MatchServiceTestCase.leagueService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'leagueService'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Found 4 fields on class org.springframework.test.AbstractTransactionalSpringContextTests
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected org.springframework.transaction.PlatformTransactionManager org.springframework.test.AbstractTransactionalSpringContextTests.transactionManager
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'transactionManager'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected org.springframework.transaction.TransactionStatus org.springframework.test.AbstractTransactionalSpringContextTests.transactionStatus
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'transactionStatus'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private boolean org.springframework.test.AbstractTransactionalSpringContextTests.defaultRollback
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private boolean org.springframework.test.AbstractTransactionalSpringContextTests.complete
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Found 10 fields on class org.springframework.test.AbstractDependencyInjectionSpringContextTests
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: public static final int org.springframework.test.AbstractDependencyInjectionSpringContextTests.AUTOWIRE_NO
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: public static final int org.springframework.test.AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: public static final int org.springframework.test.AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_TYPE
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private boolean org.springframework.test.AbstractDependencyInjectionSpringContextTests.populateProtectedVariables
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private int org.springframework.test.AbstractDependencyInjectionSpringContextTests.autowireMode
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private boolean org.springframework.test.AbstractDependencyInjectionSpringContextTests.dependencyCheck
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected org.springframework.context.ConfigurableApplicationContext org.springframework.test.AbstractDependencyInjectionSpringContextTests.applicationContext
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Rejected managed variable 'applicationContext'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: protected java.lang.String[] org.springframework.test.AbstractDependencyInjectionSpringContextTests.managedVariableNames
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Added managed variable 'managedVariableNames'
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: private int org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadCount
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Candidate field: static java.lang.Class org.springframework.test.AbstractDependencyInjectionSpringContextTests.class$org$springframework$test$AbstractSpringContextTests
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Populated field: protected com.mobilebox.squasher.service.MatchService com.mobilebox.squasher.test.MatchServiceTestCase.matchService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Populated field: protected com.mobilebox.squasher.service.UserService com.mobilebox.squasher.test.MatchServiceTestCase.userService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Populated field: protected com.mobilebox.squasher.service.LeagueService com.mobilebox.squasher.test.MatchServiceTestCase.leagueService
DEBUG (2006-02-08) 14:17.41:515 [com.mobilebox.squasher.test.MatchServiceTestCase] Populated field: protected org.springframework.transaction.PlatformTransactionManager org.springframework.test.AbstractTransactionalSpringContextTests.transactionManager
WARN (2006-02-08) 14:17.41:531 [com.mobilebox.squasher.test.MatchServiceTestCase] No bean with name 'transactionStatus'
WARN (2006-02-08) 14:17.41:531 [com.mobilebox.squasher.test.MatchServiceTestCase] No bean with name 'managedVariableNames'
INFO (2006-02-08) 14:17.41:531 [org.springframework.jdbc.datasource.JdbcTransactionObjectSupport] JDBC 3.0 Savepoint class is available
INFO (2006-02-08) 14:17.41:609 [com.mobilebox.squasher.test.MatchServiceTestCase] Began transaction: transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@1e3bbd7]; defaultRollback true
INFO (2006-02-08) 14:17.41:656 [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
INFO (2006-02-08) 14:17.41:703 [org.springframework.jdbc.support.SQLErrorCodesFactory] SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
Hibernate: select schedule0_.id as id4_4_, schedule0_.version as version4_4_, schedule0_.round_id as round3_4_4_, schedule0_.group_id as group4_4_4_, round1_.id as id3_0_, round1_.version as version3_0_, round1_.season_id as season5_3_0_, round1_.start as start3_0_, round1_.finish as finish3_0_, season2_.id as id5_1_, season2_.version as version5_1_, season2_.name as name5_1_, season2_.league_id as league6_5_1_, season2_.start as start5_1_, season2_.finish as finish5_1_, group3_.id as id0_2_, group3_.version as version0_2_, group3_.name as name0_2_, group3_.league_id as league5_0_2_, group3_.rank as rank0_2_, league4_.id as id1_3_, league4_.version as version1_3_, league4_.name as name1_3_, league4_.privateleague as privatel4_1_3_, league4_.scoringrules_id as scoringr5_1_3_ from Schedule schedule0_ inner join Round round1_ on schedule0_.round_id=round1_.id left outer join Season season2_ on round1_.season_id=season2_.id inner join LeagueGroup group3_ on schedule0_.group_id=group3_.id left outer join League league4_ on group3_.league_id=league4_.id where schedule0_.id=?
Hibernate: select scoringrul0_.id as id2_0_, scoringrul0_.version as version2_0_, scoringrul0_.pointsforplay as pointsfo3_2_0_, scoringrul0_.pointsforset as pointsfo4_2_0_, scoringrul0_.scoretowin as scoretowin2_0_, scoringrul0_.pointsforwinner as pointsfo6_2_0_, scoringrul0_.minsetsnumber as minsetsn7_2_0_ from ScoringRules scoringrul0_ where scoringrul0_.id=?
Hibernate: select match0_.id as id7_2_, match0_.version as version7_2_, match0_.date as date7_2_, match0_.status as status7_2_, match0_.winner_id as winner6_7_2_, match0_.registrationdate as registra5_7_2_, player1_.id as id10_0_, player1_.version as version10_0_, player1_.image_id as image15_10_0_, player1_.contact_cell as contact3_10_0_, player1_.contact_email as contact4_10_0_, player1_.contact_phone as contact5_10_0_, player1_.firstname as firstname10_0_, player1_.lastname as lastname10_0_, player1_.birthdate as birthdate10_0_, player1_.racquetmodel as racquetm9_10_0_, player1_.ggnumber as ggnumber10_0_, player1_.icqnumber as icqnumber10_0_, player1_.tlenid as tlenid10_0_, player1_.comments as comments10_0_, player1_.experience as experience10_0_, image2_.id as id13_1_, image2_.version as version13_1_, image2_.content as content13_1_ from SquashMatch match0_ left outer join Player player1_ on match0_.winner_id=player1_.id left outer join Image image2_ on player1_.image_id=image2_.id where match0_.id=?
Hibernate: select matches0_.schedule as schedule3_, matches0_.squashMatch as squashMa2_3_, match1_.id as id7_0_, match1_.version as version7_0_, match1_.date as date7_0_, match1_.status as status7_0_, match1_.winner_id as winner6_7_0_, match1_.registrationdate as registra5_7_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from ScheduleMatches matches0_ left outer join SquashMatch match1_ on matches0_.squashMatch=match1_.id left outer join Player player2_ on match1_.winner_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where matches0_.schedule=?
Hibernate: select players0_.squashMatch as squashMa1_2_, players0_.player as player2_, players0_.idx as idx2_, player1_.id as id10_0_, player1_.version as version10_0_, player1_.image_id as image15_10_0_, player1_.contact_cell as contact3_10_0_, player1_.contact_email as contact4_10_0_, player1_.contact_phone as contact5_10_0_, player1_.firstname as firstname10_0_, player1_.lastname as lastname10_0_, player1_.birthdate as birthdate10_0_, player1_.racquetmodel as racquetm9_10_0_, player1_.ggnumber as ggnumber10_0_, player1_.icqnumber as icqnumber10_0_, player1_.tlenid as tlenid10_0_, player1_.comments as comments10_0_, player1_.experience as experience10_0_, image2_.id as id13_1_, image2_.version as version13_1_, image2_.content as content13_1_ from MatchPlayers players0_ left outer join Player player1_ on players0_.player=player1_.id left outer join Image image2_ on player1_.image_id=image2_.id where players0_.squashMatch=?
Hibernate: select sets0_.squashMatch as squashMa4_3_, sets0_.id as id3_, sets0_.idx as idx3_, sets0_.id as id9_2_, sets0_.version as version9_2_, sets0_.winner_id as winner3_9_2_, player1_.id as id10_0_, player1_.version as version10_0_, player1_.image_id as image15_10_0_, player1_.contact_cell as contact3_10_0_, player1_.contact_email as contact4_10_0_, player1_.contact_phone as contact5_10_0_, player1_.firstname as firstname10_0_, player1_.lastname as lastname10_0_, player1_.birthdate as birthdate10_0_, player1_.racquetmodel as racquetm9_10_0_, player1_.ggnumber as ggnumber10_0_, player1_.icqnumber as icqnumber10_0_, player1_.tlenid as tlenid10_0_, player1_.comments as comments10_0_, player1_.experience as experience10_0_, image2_.id as id13_1_, image2_.version as version13_1_, image2_.content as content13_1_ from MatchSet sets0_ left outer join Player player1_ on sets0_.winner_id=player1_.id left outer join Image image2_ on player1_.image_id=image2_.id where sets0_.squashMatch=?
Hibernate: select scores0_.squashSet as squashSet3_, scores0_.score as score3_, scores0_.idx as idx3_, playerscor1_.id as id8_0_, playerscor1_.version as version8_0_, playerscor1_.player_id as player4_8_0_, playerscor1_.score as score8_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from SetScore scores0_ left outer join PlayerScore playerscor1_ on scores0_.score=playerscor1_.id left outer join Player player2_ on playerscor1_.player_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where scores0_.squashSet=?
Hibernate: select scores0_.squashSet as squashSet3_, scores0_.score as score3_, scores0_.idx as idx3_, playerscor1_.id as id8_0_, playerscor1_.version as version8_0_, playerscor1_.player_id as player4_8_0_, playerscor1_.score as score8_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from SetScore scores0_ left outer join PlayerScore playerscor1_ on scores0_.score=playerscor1_.id left outer join Player player2_ on playerscor1_.player_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where scores0_.squashSet=?
Hibernate: select scores0_.squashSet as squashSet3_, scores0_.score as score3_, scores0_.idx as idx3_, playerscor1_.id as id8_0_, playerscor1_.version as version8_0_, playerscor1_.player_id as player4_8_0_, playerscor1_.score as score8_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from SetScore scores0_ left outer join PlayerScore playerscor1_ on scores0_.score=playerscor1_.id left outer join Player player2_ on playerscor1_.player_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where scores0_.squashSet=?
Hibernate: select points0_.squashMatch as squashMa1_3_, points0_.points as points3_, points0_.idx as idx3_, playerscor1_.id as id8_0_, playerscor1_.version as version8_0_, playerscor1_.player_id as player4_8_0_, playerscor1_.score as score8_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from MatchPoints points0_ left outer join PlayerScore playerscor1_ on points0_.points=playerscor1_.id left outer join Player player2_ on playerscor1_.player_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where points0_.squashMatch=?
Hibernate: select scores0_.squashMatch as squashMa1_3_, scores0_.score as score3_, scores0_.idx as idx3_, playerscor1_.id as id8_0_, playerscor1_.version as version8_0_, playerscor1_.player_id as player4_8_0_, playerscor1_.score as score8_0_, player2_.id as id10_1_, player2_.version as version10_1_, player2_.image_id as image15_10_1_, player2_.contact_cell as contact3_10_1_, player2_.contact_email as contact4_10_1_, player2_.contact_phone as contact5_10_1_, player2_.firstname as firstname10_1_, player2_.lastname as lastname10_1_, player2_.birthdate as birthdate10_1_, player2_.racquetmodel as racquetm9_10_1_, player2_.ggnumber as ggnumber10_1_, player2_.icqnumber as icqnumber10_1_, player2_.tlenid as tlenid10_1_, player2_.comments as comments10_1_, player2_.experience as experience10_1_, image3_.id as id13_2_, image3_.version as version13_2_, image3_.content as content13_2_ from MatchScore scores0_ left outer join PlayerScore playerscor1_ on scores0_.score=playerscor1_.id left outer join Player player2_ on playerscor1_.player_id=player2_.id left outer join Image image3_ on player2_.image_id=image3_.id where scores0_.squashMatch=?
Running time: 0:00:00.641.
Hibernate: update Schedule set version=?, round_id=?, group_id=? where id=? and version=?
Hibernate: update SquashMatch set version=?, date=?, status=?, winner_id=?, registrationdate=? where id=? and version=?
Hibernate: update MatchSet set version=?, winner_id=? where id=? and version=?
WARN (2006-02-08) 14:17.42:343 [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 01004
ERROR (2006-02-08) 14:17.42:343 [org.hibernate.util.JDBCExceptionReporter] Data truncation: Column set to default value; NULL supplied to NOT NULL column 'winner_id' at row 1
ERROR (2006-02-08) 14:17.42:343 [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not update: [com.mobilebox.squasher.model.match.MatchSet#1120]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2222)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:496)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:469)
at org.springframework.test.AbstractTransactionalSpringContextTests.endTransaction(AbstractTransactionalSpringContextTests.java:209)
at org.springframework.test.AbstractTransactionalSpringContextTests.onTearDown(AbstractTransactionalSpringContextTests.java:153)
at org.springframework.test.AbstractDependencyInjectionSpringContextTests.tearDown(AbstractDependencyInjectionSpringContextTests.java:305)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Column set to default value; NULL supplied to NOT NULL column 'winner_id' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1124)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:676)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
... 27 more
ERROR (2006-02-08) 14:17.42:453 [com.mobilebox.squasher.test.MatchServiceTestCase] onTearDown error
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not update: [com.mobilebox.squasher.model.match.MatchSet#1120]; uncategorized SQLException for SQL [update MatchSet set version=?, winner_id=? where id=? and version=?]; SQL state [01004]; error code [0]; Data truncation: Column set to default value; NULL supplied to NOT NULL column 'winner_id' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Column set to default value; NULL supplied to NOT NULL column 'winner_id' at row 1
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Column set to default value; NULL supplied to NOT NULL column 'winner_id' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1124)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:676)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:496)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:469)
at org.springframework.test.AbstractTransactionalSpringContextTests.endTransaction(AbstractTransactionalSpringContextTests.java:209)
at org.springframework.test.AbstractTransactionalSpringContextTests.onTearDown(AbstractTransactionalSpringContextTests.java:153)
at org.springframework.test.AbstractDependencyInjectionSpringContextTests.tearDown(AbstractDependencyInjectionSpringContextTests.java:305)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:47 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
try specifying a cascade attrubute for the association.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:57 pm 
Regular
Regular

Joined: Wed May 05, 2004 8:01 am
Posts: 53
This is not the problem. When removing match a player stay in database (after all there are his/hers other matches registered).

So:

performing: dao.delete( match ) should

- delete all match sets:
delete from MatchSet ms where ms.squashMatch_id = ?

- delete a match
delete from Match m where m.id = ?

nothing more. What is being performed is:

update MatchSet ms set ms.winner_id = ?;
delete from MatchSet ms where ms.squashMatch_id = ?
delete from Match m where m.id = ?

the first sql query tries to remove the reference to Player entity which fails because MatchSet.winner is modelled as NOT NULL (and should stay this way).

Does it clear the situation a little bit?
Does anyone know why deleting MatchSet is being performed using 2 SQL queries (an update and an actual delete) instead of simple delete?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 4:14 pm 
Regular
Regular

Joined: Wed May 05, 2004 8:01 am
Posts: 53
Never mind. I have found the problem. Maciej has posted me a full model and it looks like one of collections - Match.getPlayers() was incorrectly annotated with @Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN). This was the cause of all problems.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.