Does your book suggest how to achieve findByExample in JPA?
For e.g. if I have an object with 4 instance variables, I fill random 2 of them and try to search. Is it suggested in JPA2 book?
I'm sorry to say that we didn't actually get to do QBE in JPA 2.0. Criteria API does not have any special operators for it so entity equality is just like in JP QL, based on PK value. Sorry, but hopefully we'll be more successful on that front in the next go-round. For now it is one of those vendor features that every vendor supports, but is not in the spec yet.
Mike Keith wrote:I'm sorry to say that we didn't actually get to do QBE in JPA 2.0. Criteria API does not have any special operators for it so entity equality is just like in JP QL, based on PK value. Sorry, but hopefully we'll be more successful on that front in the next go-round. For now it is one of those vendor features that every vendor supports, but is not in the spec yet.
Really, I kind of assumed if there was a Criteria object here was QBE. ;)
Mike Keith wrote:I'm sorry to say that we didn't actually get to do QBE in JPA 2.0. Criteria API does not have any special operators for it so entity equality is just like in JP QL, based on PK value. Sorry, but hopefully we'll be more successful on that front in the next go-round. For now it is one of those vendor features that every vendor supports, but is not in the spec yet.
Ok, well I think you can give sample code for QBE in JPA 2.0 on web-page dedicated for the book. I am sure this feature comes among the most sought after ones in ORM community.
Mike Keith
author
Ranch Hand
Joined: Jul 14, 2005
Posts: 304
posted
0
We have tried to keep the book focused on the specification. Since this is a vendor feature then vendor documentation will generally cover this. If you really want a code example that uses QBE, though, here is a sample of using it in the EclipseLink JPA 2.0 reference implementation:
Mike Keith wrote:We have tried to keep the book focused on the specification. Since this is a vendor feature then vendor documentation will generally cover this. If you really want a code example that uses QBE, though, here is a sample of using it in the EclipseLink JPA 2.0 reference implementation:
Thanks for the code. It looks like there's no vendor neutral way to achieve it.