Habe mich heute das erste Mal an Insert Statements getraut und prompt gibts einen Fehler ;-)
Habe folgendes einfaches Beispiel:
Code:
public void InsertTest() throws Exception {
Session session = HibernateUtil.currentSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
EtTest test = new EtTest();
test.setText("Test");
session.saveOrUpdate(test);
tx.commit();
}
catch (Exception ex) {
if (tx != null)
tx.rollback();
msg = bundle.getString("testnachricht");
context.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_WARN, msg, null));
throw ex;
}
finally {
HibernateUtil.closeSession();
}
}
Das Mapping File dazu:
Code:
<hibernate-mapping schema="EDITOOLS" package="com.magnasteyr.editool.hibernate">
<class name="EtTest" dynamic-update="true" dynamic-insert="true" lazy="false" table="ET_TEST" schema="EDITOOLS">
<id name="id" type="long" unsaved-value="null">
<column name="ID" not-null="true" index="SYS_C0063013" sql-type="NUMBER"/>
<generator class="sequence"/>
</id>
<property name="text" type="string">
<column name="TEXT" sql-type="VARCHAR2"/>
</property>
</class>
</hibernate-mapping>
Wenn ich nun diese Methode ausführe, wird zwar in die Datenbank geschrieben, trotzdem erhalte ich in Eclipse folgende Meldung (Oben seht ihr auch noch das Select Statement, dass ausgeführt wird):
Code:
Hibernate: select EDITOOLS.hibernate_sequence.nextval from dual
Hibernate: /* insert com.magnasteyr.editool.hibernate.EtTest */ insert into EDITOOLS.ET_TEST (TEXT, ID) values (?, ?)
Problem with checked-in Statement, discarding.
java.lang.NullPointerException
at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.refreshStatement(GooGooStatementCache.java:410)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.checkinStatement(GooGooStatementCache.java:129)
at com.mchange.v2.c3p0.impl.NewPooledConnection.checkinStatement(NewPooledConnection.java:143)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.close(NewProxyPreparedStatement.java:1806)
at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:417)
at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:197)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:177)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.magnasteyr.editool.hibernate.helpers.QueryHelper.InsertDBKZ(QueryHelper.java:755)
at com.magnasteyr.editool.dto.SearchDto.listSearchResults(SearchDto.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
Hab ich da irgendwas vergessen?Ich mein, dass is ja jetzt noch ein einfaches Beispiel und trotzdem fliegt er da...Verstehe ned ganz, wo die NullPointerException herkommt.
Bitte um Hilfe!
Mfg
Hibernate version:
3.0.5