Joined: Wed Apr 27, 2005 1:30 pm Posts: 7
|
Hi,
For some time i have been reading the theory behind hibernate and thinking i understood it. Now with a new project i am under taking i have encountered some problems. Any tips would help
Hibernate version: 2.1.4 (Should i use 3 as this is a new startup project?)
Mapping documents:
Middlegen generated.
<class
name="Product"
table="products"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="products"
</meta>
<id
name="id"
type="java.lang.Integer"
column="ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="native"
type="java.lang.Integer"
column="ID"
</meta>
<generator class="native" />
</id>
Code between sessionFactory.openSession() and session.close():
Using Spring support for hibernate. this works fine as i can select from tables ok. its just on insert i am having issues.
Name and version of the database you are using:
MYSql 4.1
Questions I have.
Firstly should i be using Hibernate 3. Using 2 as his is the version i have done my sample apps on.
I use generator classes = native. My table have a primary of int and auto_increment is set to true.
It firstly complained about not having table hibernate_unique_key in my schema (I found some posts and retrieved a ddl for this table) why is this table needed?
Now i am getting complaints that
49872 [Servlet.Engine.Transports:10] ERROR util.JDBCExceptionReporter - Could not save object
java.sql.SQLException: Can't call commit when autocommit=true
My SqL URL :
Spring Managed:
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>org.gjt.mm.mysql.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost/dbname?relaxAutoCommit=true</value></property>
<property name="username"><value></value></property>
<property name="password"><value></value></property>
</bean>
Any help would be great. I thought that using native it would be fine.
_________________ Tell me, I'll forget. Show me, I may remember. But involve me, and I'll understand.
|
|