I think something is wrong with my list of url in the class item.
When persisting it locks after inserting into the url table.No exception or anything.
If i remove the list from the mapping it works.
Hibernate version:
3
Mapping documents:
Item:
<hibernate-mapping>
<class name="Item" table="items" lazy="false">
<cache usage="read-write" />
...
<list name="pictures" cascade="save-update,persist">
<key column="saleitem_id"/>
<index column="idx"/>
<one-to-many class="Url"/>
</list>
...
</class>
</hibernate-mapping>
Url:
<hibernate-mapping>
<class name="Url" table="url" lazy="false">
<cache usage="read-write" />
<id name="id" column="id">
<generator class="increment"/>
</id>
<property name="domain">
<column name="domain"/>
</property>
<property name="path">
<column name="path"/>
</property>
<property name="filename">
<column name="filename"/>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Serializable id = session.save(item);
return Integer.parseInt(id.toString());
}
};
return (Integer) getHibernateTemplate().execute(callback);
Full stack trace of any exception that occurs:
Nothing-
Name and version of the database you are using:
Mysql 5.0.44
The generated SQL (show_sql=true):
Hibernate: select max(id) from items
Hibernate: select max(id) from sellers
Hibernate: select max(id) from prices
Hibernate: select max(id) from item_locations
Hibernate: select max(id) from url
Hibernate: insert into sellers (company, name, email, phone, hidephone, id) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into prices (currency, amount, id) values (?, ?, ?)
Hibernate: insert into prices (currency, amount, id) values (?, ?, ?)
Hibernate: insert into item_locations (city_id, id) values (?, ?)
Hibernate: insert into items (category_id, dateAdded, itemName, seller_id, itemDescription, price_id, oldPrice_id, location_id, password, type, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into url (domain, path, filename, id) values (?, ?, ?, ?)
SQL
CREATE TABLE `url` (
`id` bigint(20) NOT NULL auto_increment,
`idx` int(11) NOT NULL,
`saleitem_id` bigint(20) NOT NULL,
`domain` varchar(150) NOT NULL,
`path` varchar(150) NOT NULL,
`filename` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK1C56FBBF0AE19` (`saleitem_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE `items` (
`id` int(11) NOT NULL auto_increment,
`category_id` int(11) NOT NULL,
`dateAdded` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`itemName` varchar(150) NOT NULL,
`seller_id` int(11) NOT NULL,
`itemDescription` varchar(500) NOT NULL,
`price_id` int(11) NOT NULL,
`oldPrice_id` int(11) NOT NULL,
`location_id` int(11) NOT NULL,
`password` varchar(25) NOT NULL,
`type` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKFA883BD9E3859AFB` (`price_id`),
KEY `FKFA883BD9679E2CCC` (`location_id`),
KEY `FKFA883BD96C663222` (`oldPrice_id`),
KEY `FKFA883BD9B60B6F99` (`seller_id`),
KEY `FKFA883BD92DD27779` (`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
|