Hi,
I have two tables in my database. USER(username, roleID, passwd) and ROLE(roleID, name). Role contains only two entries:
Quote:
1,Admin
2,Customer
the following code
Code:
session.createQuery("from User").list();
Provides me a list of User objects.
Quote:
usera,Admin,securepasswd
userb,Customer,moresecurepasswd
When changes made directly to the underlying database, e.g. to change a user role:
Code:
update user set roleid=1 where username like 'userb';
nothing happens. If i launch a new query on my running session, the result is the same as before.
On the other hand, if I make a new user. session.createQuery delivers me this new user immediately.
here are the two mapping documents:
User.hbm.xml:
Code:
<hibernate-mapping>
<class name="namespace.User" table="user" schema="public">
<id name="username" type="string">
<column name="username" length="20" />
<generator class="assigned" />
</id>
<many-to-one name="role" class="namespace.Role" fetch="select" >
<column name="roleid" />
</many-to-one>
<property name="passwd" type="string">
<column name="passwd" length="64"/>
</property>
</class>
</hibernate-mapping>
Role.hbm.xml
Code:
<hibernate-mapping>
<class name="namespace.Role" table="role" schema="public">
<id name="roleid" type="int">
<column name="roleid" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name" length="30" />
</property>
</class>
</hibernate-mapping>
I guess it has something to do with the mapping between these two tables, but I didn't get into it.
Any help would be really appreciated.
Thanks!
Christian