I changed my product mapping to this, to get a generated ID from the db. When I did this, hibernate will try and update instead of inserting the data into the database. Not sure why on this.
<class name="Product" table="Product">
<id name="productId" column="productId" type="long" unsaved-value="null"> <generator class="hilo"></generator> </id> <property name="productName" column="productName" type="string" length="15" not-null="false"/>
<property name="productPrice" column="productPrice" type="double" not-null="false"/>
<property name="productDescription" column="productDescription" type="string"
length="50" not-null="false"/>
<many-to-one name="company" class="Company" column="companyId" not-null="true"/>
</class>
Hibernate: select employee_.ssn, employee_.firstName, employee_.lastName as lastName1_, employee_.salary as salary1_, employee_.companyId as companyId1_ from Employee employee_ where employee_.ssn=? and employee_.firstName=?
Hibernate: select employee_.ssn, employee_.firstName, employee_.lastName as lastName1_, employee_.salary as salary1_, employee_.companyId as companyId1_ from Employee employee_ where employee_.ssn=? and employee_.firstName=?
Hibernate: insert into Company (companyName, address, companyId) values (?, ?, ?)
Hibernate: insert into Employee (lastName, salary, companyId, ssn, firstName) values (?, ?, ?, ?, ?)
Hibernate: insert into Employee (lastName, salary, companyId, ssn, firstName) values (?, ?, ?, ?, ?)
Hibernate: insert into Company (companyName, address, companyId) values (?, ?, ?)
Hibernate: insert into Company (companyName, address, companyId) values (?, ?, ?)
Hibernate: update Product set productName=?, productPrice=?, productDescription=?, companyId=? where productId=?
|