In Oracle databases, when querying data using Hibernate, especially when querying for data using the View object, some fields are empty when the entire record is not available, because when the XML file and the Pojo (bean) file are generated, Because view does not have a primary key argument, so it generates a Pojo class and a corresponding ID class (primary key Class), and this ID class is all the fields in view, and that Pojo class is a field of this ID class, and when Hibernate gets the record, the primary key class is empty and the record is discarded. So if you use the view's Pojo class to query the data, a field is blank, the entire record is empty, and if all the records have one field blank, the number of records you get is 0.
Workaround:
1, rewrite the ID class and the Pojo class, and put the non-empty fields, such as using the primary key in the original table as the ID class field, the other fields are written in the Pojo class, and provide the Getter/setter method.
2, write the XML file:
Change a non-primary key field to a generic field, for example, one of the following non-primary key fields is modified to:
<composite-id name= "id" class= "com.bl.pojo.ViewBlParseAllScoreId" >
<key-property name= "Subschoolid" type= "Java.lang.Long" >
<column name= "sub_school_id" precision= "a" scale= "0"/>
</key-property>
</composite-id>
After modification
<property name= "Subschoolid" type= "Java.lang.Long" >
<column name= "sub_school_id" precision= "a" scale= "0"/>
</property>
This can be.