开发者

hibernate mapping of 2 column table

开发者 https://www.devze.com 2023-03-20 03:27 出处:网络
I have a table with 2 varchar columns key,value used to store config for an application. (key column is aso the primary key) Is there any other way to use it in hibernate than native sql queries? Can

I have a table with 2 varchar columns key,value used to store config for an application. (key column is aso the primary key) Is there any other way to use it in hibernate than native sql queries? Can one do any object mapping that would expose this v开发者_高级运维alues?

thanks


Sure. Create class ConfigurationItem with two properties: String key, String value. Map them to the appropriate fields with the key mapped as the id column. Then to load them just session.createQuery("from ConfigurationItem").list()

0

精彩评论

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