Hi everyone,
I am trying to make an insert but nothing happens in my database. This is my User class:
Code:
public class User implements Serializable {
private int id = 0;
private String login = null;
private String password = null;
private Date creationDate = null;
private Profile profile = null;
private UserCategory userCategory = null;
private List<Resource> resourceList = null;
private List<Item> itemList = null;
..................
}
my mapping file:
Code:
<hibernate-mapping package="com.model.user.web" auto-import="false">
<class name="User" table="user" lazy="true">
<id name="id" type="integer" column="id" unsaved-value="null">
<generator class="native"/>
</id>
<property name="login" type="string" column="login" length="10" not-null="true" unique="true"/>
<property name="password" type="string" column="password" length="100" not-null="true"/>
<property name="creationDate" column="creation_date" type="java.util.Date" update="false" not-null="true"/>
<one-to-one name="profile" class="Profile" cascade="all" />
<many-to-one name="userCategory" cascade="none" class="com.model.category.UserCategory" foreign-key="user_fk_id_category">
<column name="id_category" not-null="false" />
</many-to-one>
<list name="resourceList" lazy="true" inverse="true">
<key column="id_user"/>
<list-index column="start"/>
<one-to-many class="com.model.resource.Resource"/>
</list>
<list name="itemList" lazy="true" inverse="true">
<key column="id_user"/>
<list-index column="start"/>
<one-to-many class="com.model.item.Item"/>
</list>
</class>
</hibernate-mapping>
this is my insert makePersistent() method:
Code:
public void makePersistent(User user) throws InfrastructureException {
try {
HibernateUtil.getSession().saveOrUpdate(user);
HibernateUtil.commitTransaction();
} catch (HibernateException ex) {
HibernateUtil.rollbackTransaction();
throw new InfrastructureException(ex);
} finally {
HibernateUtil.closeSession();
}
}
Can someone help me? Any idea of what is going on?
Thanks in advance