I am using Annotations 3.0 alpha 2 + Hibernate 3.0 beta2. I have an Account class with a property like this:
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="role_id", unique=false, nullable=false)
public Role getRole() {
return role;
}
And the Role class like this:
@Id(generate=GeneratorType.AUTO)
public Long getId() {
return id;
}
and so on...
I got this when accessing the Role methods after loading a saved Account from the database and closing the session:
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
I thought the lazy was disabled by default on OneToOne, and looking at the Account loading logs, i see that it's not true:
DEBUG [main] resolving associations for [it.airventsam.markab.core.security.Account#294913]
DEBUG [main] loading entity: [it.airventsam.markab.core.security.Role#327681]
DEBUG [main] creating new proxy for entity
Why that? I dont want proxies because i need to access that data after session is closed. Can you help me?
|