Hi ,
I am completly new to Hibernate, I was trying a sample example.
I have a table called Login on SQL server 2000.
When i try to save the records ,
//CODE
Login log=new Login(); log.setUsername("USER"); log.setPassword("PWD"); session.save(log); tx.commit();
//END OF CODE
it throws me the below exception
net.sf.hibernate.exception.ConstraintViolationException: could not insert: [org.Login] at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:62) at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426) at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749) at org.Test.main(Test.java:26) Caused by: com.inet.tds.SQLException: Msg 515, Level 16, State 2, Line 1, Sqlstate 23000 [AEDXB-ASHKAR]Cannot insert the value NULL into column 'UserName', table 'Telecom_HelpDesk.dbo.Login'; column does not allow nulls. INSERT fails. at com.inet.tds.q.a(Unknown Source) at com.inet.tds.a.a(Unknown Source) at com.inet.tds.k.a(Unknown Source) at com.inet.tds.k.a(Unknown Source) at com.inet.tds.k.b(Unknown Source) at com.inet.tds.d.f(Unknown Source) at com.inet.tds.d.execute(Unknown Source) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:502) ... 8 more
My Mapping XML IS
<hibernate-mapping package="org">
<class name="Login" table="Login">
<id name="username" column="UserName" type="string">
<generator class="native"/>
</id>
<property name="password" column="Password" type="string" />
</class>
</hibernate-mapping>
I can retrive records but cannot save
Please Help.
Thanks a million in Advance
|