Java – HQL query minus some specific fields

HQL query can retrieve every field except one

It's like:

session.get(entityClass,id).withoutThisField(fieldNotDesired)

Example: I have a class picture (int ID, string name, byte [] file)

I want to retrieve all pictures except field files

I know I can do this if I fill in the required fields exactly, but I don't want to update my query every time I add a new field

I know that if the field is a blob, it will only be retrieved if necessary This is not my case And bytecode detection is accurate to a field, lazy = true does not work, I have a strange exception

Thank you in advance

Solution

I recommend using an inherited class

Make picturefile a subclass of picture and add only one field file

In your example, you can get pictures When you need a blob file, get picturefile

I find myself often creating several alternative mappings for entities based on such specific requirements

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>