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.....