athegra wrote:
Please post and tell me if this was usefull and if you have other problems.
A good suggestion. I did try this with and without the targetEntity tag, to no avail.
Cameron McKenzie wrote:
Code:
Session session = HibernateUtil.beginTransaction();
session.save(student01);
session.save(student02);
session.save(student03);
session.save(student04);
session.save(java101);
session.save(cplus101);
session.save(math101);
HibernateUtil.commitTransaction();
}
Code:
xxxxUsersEntity user = new xxxxUsersEntity();
user.setLastName("Ratcliffe");
user.setFirstName("John");
AddressEntity address = new AddressEntity();
address.setStreet("1234 Powatan Circle");
address.setCity("Jamestown");
address.setState("VA");
address.setZip("23606");
user.getAddress().add(address);
session.save(user);
session.save(address);
System.out.println("Record Inserted");
session.getTransaction().commit();
session.close();
Trying this method and got the following:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
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 com.xxxx.users.AddUser.main(AddUser.java:30)
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:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.sql.BatchUpdateException: ORA-00904: "ADR_ID": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 13 more
I am at a loss, for sure!
Thanks in advance,
Mark