# Anfänger: Hibernate + Web



## KlinCh (18. Mai 2009)

Hi,
Ich sitze hier schon über eine Stunde am selben Problem.
Ich bin mir nicht sicher ob es hieran liegt, wenn nicht, dann poste ich noch mehr quellcode:


```
public class Player{
...
public void processEffect(Effect effect){
        Session session = InitHibernate.getSessionFactory().getCurrentSession();
        Transaction tx = session.beginTransaction();
        Player ptemp = (Player) session.merge(this);
        
        ptemp.calculations.add(
                new Calculation(Calculation.CAT_EVENT,
                "Ereignis",
                effect.getCosts(),
                effect.getText())
        );
        ptemp.skill.add(effect.getSkill());
        ptemp.score.add(effect.getScore());
        if(effect.getLeavingStaff() != null){
            ptemp.staff.remove(effect.getLeavingStaff());
        }
        tx.commit();
    }
...
}
```

Die Exception lautet:

```
SCHWERWIEGEND: Could not synchronize database state with session
org.hibernate.exception.DataException: could not insert: [mySchool.gameObjects.events.ChaosEvent]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
        at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at mySchool.gameObjects.Player.processEffect(Player.java:274)
        at mySchool.web.components.ChaosEventFrame$1.actionPerformed(ChaosEventFrame.java:54)
        at nextapp.echo2.app.button.AbstractButton.fireActionPerformed(AbstractButton.java:135)
        at nextapp.echo2.app.button.AbstractButton$1.actionPerformed(AbstractButton.java:100)
        at nextapp.echo2.app.button.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:70)
        at nextapp.echo2.app.button.DefaultButtonModel.doAction(DefaultButtonModel.java:58)
        at nextapp.echo2.app.button.AbstractButton.doAction(AbstractButton.java:121)
        at nextapp.echo2.app.button.AbstractButton.processInput(AbstractButton.java:506)
        at nextapp.echo2.app.update.ClientUpdateManager.process(ClientUpdateManager.java:116)
        at nextapp.echo2.app.update.UpdateManager.processClientUpdates(UpdateManager.java:89)
        at nextapp.echo2.webcontainer.ContainerSynchronizeService.renderUpdate(ContainerSynchronizeService.java:472)
        at nextapp.echo2.webrender.service.SynchronizeService.service(SynchronizeService.java:279)
        at nextapp.echo2.webrender.WebRenderServlet.process(WebRenderServlet.java:273)
        at nextapp.echo2.webrender.WebRenderServlet.doPost(WebRenderServlet.java:189)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:636)
Caused by: org.apache.derby.client.am.SqlException: Bei dem Versuch, VARCHAR () FOR BIT DATA 'XX-RESOLVE-XX' auf die Länge 255 zu kürzen, ist ein Abschneidefehler aufgetreten.
        at org.apache.derby.client.am.Statement.completeExecute(Unknown Source)
        at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
        at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
        at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
        at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source)
        at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
        ... 40 more
```

Danke schonmal.


----------



## void (18. Mai 2009)

KlinCh hat gesagt.:


> ```
> Caused by: org.apache.derby.client.am.SqlException: Bei dem Versuch, VARCHAR () FOR BIT DATA 'XX-RESOLVE-XX' auf die Länge 255 zu kürzen, ist ein Abschneidefehler aufgetreten.
> ```



Ein Wert den du einfügen willst ist größer als 255 Zeichen.


----------



## KlinCh (22. Mai 2009)

Ne, das war nicht der Fehler, ich arbeite ja garnicht auf sql-ebene danke hibernate.

Das Problem war das eine Klasse nicht ordnungsgemäß gemappt war, auch wenn man das aus der Exception nur schwer erkennen konnte.

Trotzdem danke.

P.S: kann man hier irgendwie Thread closen oder als "Erledigt" markieren?


----------

