开发者

Hibernate query with partial key

开发者 https://www.devze.com 2023-01-06 07:24 出处:网络
I have two database tables, both mapped using Hibernate. The first table has a primary key with one field. The second has a composite primary key with three fields. Suppose I try to fetch results from

I have two database tables, both mapped using Hibernate. The first table has a primary key with one field. The second has a composite primary key with three fields. Suppose I try to fetch results from the second table by providing just the partial key (one field), then I get an exception

Exception in thread "main" org.springfr开发者_JS百科amework.orm.hibernate3.HibernateSystemException: More than one row with the given identifier was found

Any idea how I can get multiple rows with the partial key provided to a method?

Thanks for any help.


Any idea how I can get multiple rows with the partial key provided to a method?

Something like this would work:

select foo from Foo foo where foo.id.field1 = 'bar'
0

精彩评论

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