-->
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: ConstraintViolationException: could not insert, but I dont't
PostPosted: Fri Oct 05, 2007 6:34 am 
Newbie

Joined: Tue Oct 02, 2007 12:19 pm
Posts: 7
I alwaya get this exception:
Code:
exception

javax.servlet.ServletException: could not insert: [beans.Maschinendaten]
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)


root cause

org.hibernate.exception.ConstraintViolationException: could not insert: [beans.Maschinendaten]
   org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
   org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:40)
   org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
   org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
   org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
   org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
   org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
   org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
   org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
   org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
   beans.MaschinendatenHandler.processAction(MaschinendatenHandler.java:34)
   javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
   javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:487)
   javax.faces.component.UICommand.broadcast(UICommand.java:78)
   javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)


root cause

com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'betriebsmittel' cannot be null
   com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
   com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
   com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
   com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
   com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
   com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
   com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1585)
   com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1500)
   com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1485)
   org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:33)
   org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
   org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
   org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
   org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
   org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
   org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
   org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
   org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
   org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
   beans.MaschinendatenHandler.processAction(MaschinendatenHandler.java:34)
   javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
   javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:487)
   javax.faces.component.UICommand.broadcast(UICommand.java:78)
   javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)



I have a JSF-Form and I want to save the inputs with hibernate in a MySQL DB.
I create a table with 20 columns. Every column could be not null.
I think the hibernate mapping is OK.
I get the exception "Column 'betriebsmittel' cannot be null".
Thats right, because don't want that the columns are null.

When every column could be null, the action-method saves in every column "null" and in the column id (primary key) 0. But I don't want that.

I hope anyone can help me.....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 8:20 am 
Newbie

Joined: Mon Oct 01, 2007 8:59 am
Posts: 18
this exception arise when when you are trying to insert a null value where not-null is true.please check ur mapping file carefully that it should have property tag with not-null="true".
So you include not-null="true" attribute in all property tags.


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.