Thank you for your answer.
I tried what you said, but it doesnt work. I'm still doing something wrong.
my code looks like:
Code:
try{
session.save(user);
}
catch(Exception e){
e.getClass();
e.getMessage();
}
User is the new object I want to save.
The hbm.xml file looks like:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="de.fum.ag.eanv.model.impl">
<class name="User" table="users" lazy="false">
<id name="id" column="ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="username"
column="USERNAME"
length="50"
type="java.lang.String"
not-null="true"/>
<property name="password"
column="PASSWORD"
length="50"
type="java.lang.String"
not-null="true"/>
<property name="enabled"
column="ENABLED"
type="java.lang.Boolean"
not-null="true"/>
<property name="firstname"
column="VORNAME"
length="45"
type="java.lang.String"
not-null="false"/>
<property name="lastname"
column="NAME"
length="45"
type="java.lang.String"
not-null="false"/>
</class>
</hibernate-mapping>
When I took a closer look at the exception object I realized that there was an sql field coming with the exception. It said:
Code:
insert into users (USERNAME, PASSWORD, ENABLED, VORNAME, NAME) values (?, ?, ?, ?, ?)
That cant be right. Where is the id field? Where are the values of the object?
Do you know what I'm doing wrong? Do you have any hints for me?
Thank you.
Stefan