• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.exception.ConstraintViolationException

 
Babu Singh
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am making a sample program using this link:http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-one-to-one-1.html
i have following tables in sqlserver:
i have take studentId type int in Student.hbm.xml:
i have take addressId type int in Address.hbm.xml:
i am facing following exception:

please help.
 
Babu Singh
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me to resolve it.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please remember that PatienceIsAVirtue.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caused by: java.sql.SQLException: Cannot insert the value NULL into column 'ADDRESS_ID', table 'sample.dbo.Address2'; column does not allow nulls. INSERT fails


You are trying to insert NULL to ADDRESS_ID and your table definition specifies the column to be not null. Use a proper not-null value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic