Eric Pascarello wrote:They should work the same. I do not think I have ever seen anyone write it the 2nd way in production code.
I know if you do not have the () around it, it will cause an error.
Eric
Eric Pascarello wrote:Looks like an error to me on the 2nd one
Balu Sadhasivam wrote:
select distinct(name) from File where size!=0
more faster
select distinct(name) from File where size > 0
Jane Dodo wrote:
Alternatively: given an object, how do I know whether another object with the same id exists in the database? (but without knowing which fields constitute the object's id?
The only solution I can think of is parsing annotations and using reflection - yikes! There has to be an easier way.
Jeanne Boyarsky wrote:Steven,
Why do you have id in the main query? Doesn't that make it distinct? Also, note that you could get more than one record back if there are identical prices.
I would use the code you wrote because it isn't database specific. Another approach is the following. Note that your database needs to support returning only one row and you should check the performance is equivalent through your database explain plan.
Manish fico wrote:Steve,
does any of your entities in HQL follow inheritance? If thats the case, hibernate will try to sync the versions of the parent and child even in read operation.
Regards,
Manish
Paul Sturrock wrote:No. Think about it - why would a select statement require optimistic locking?
Paul Sturrock wrote:
Anybody know why? I reckon only update a table will trigger an update on the version field, right?
Yes. There is no need to update a version number if all you are doing is selecting the data.