For some reason I cannot save data into my InnoDB tables via hibernate. The InnoDB tables are being created properly, however when I execute my transaction the data does not get saved. If I manually insert the data via phpMyAdmin then it works perfectly. Im not sure what I am missing.
Here is my java code:
Code:
Customer ctmr = new Customer("John", "Doe");
ctmr.setcid(1); //Set customer ID
Fintrans fts = new Fintrans();
fts.setAmountWillingToPay(12000.05);
fts.setCustomer(ctmr);
fts.setDatetime("06/22/2006");
fts.setGrandTotalAccrued(3213.20);
fts.setGrandTotalPaid(13651.10);
fts.setReason("No reason given");
Transaction tx = null;
try{
tx = factory.openSession().beginTransaction();
Session session = factory.getCurrentSession();
session.save(fts);
tx.commit();
}catch(Exception e){
if (tx!=null)
tx.rollback();
throw e;
}
I have two tables on the same database - customer and fintrans. The fintrans table has a foreign key to the customer table (cid).
Here is my Hibernate.cfg.xml file:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">zzzzzzz</property>
<property name="connection.username">zzzzzz</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="connection.password">zzzzz</property>
<property name="connection.pool_size">10</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="current_session_context_class">org.hibernate.context.JTASessionContext</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>
<!-- this will create the database tables for us -->
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
If anyone can provide help on the matter that would be much appreciated.
Outlaw.