开发者

Hibernate/JPA/HSQLDB Enum issues

I am using Hibernate annotations and entity manager (JPA) with HSQLDB. So I have an entity with an enum field:

@Enumerated(EnumType.STRING)
@Column(name = "access_level")
public AccessLevel getAccessLevel() {
    return accessLevel;
}

Where AccessLevel is an enum. I can persist this, detach, and then query and everything is as it should be. However, once I close the EntityManagerFactory and everything flushes out to disk and then start again, this field always comes up null.

When I query the database with the HSQLDB Manager, everything is there and the column in this table contains the name of the enum element as it should. However, when I query, the entity has everything except this field is always null.

I am trying to avoid the user type business and keep it simple. What 开发者_开发问答confuses me is that it is only after closing the EntityManagerFactory that this happens. I can persist and detach the object and then merge, query, find or whatever using other EntityManagers and transactions and the enum is handled correctly.

Any clue would be helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜