In the following example, how can I save the value of role to the role with id=1 without loading it? I have tried:
Map user = new HashMap();
user.put("address","Address test"); user.put("role",1);
session.save("User",user);
But that results in:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map at org.hibernate.property.MapAccessor$MapGetter.get(MapAccessor.java:90)
And
Map user = new HashMap();
user.put("address","Address test"); user.put("role.id",1);
session.save("User",user);
Doesn't save the role, console shows this SQL: Hibernate: insert into user (ts, address) values (?, ?)
Any help will be greatly appreciated.