Hi,
I am using criteria query to fetch list of records from database VIEW.[code=java] I have created the corresponding HBM.xml and POJO files.
OuterView.hbm.xml corresponds to OuterView.java, which contains a composite key of class InnerView.java.
OuterView.java contains only one attribute as InnerView and InnerView contains all the column names and their getters and setters.
I am creating criteria on OuterView.java and the query is being fired too. But when I am fetching the returned list, it gives me a list with NULL objects in it. I cannot get the data neither in OuterView nor in InnerView.
Can you please help me out? Is there something that I am missing?
Code for reference:
HBM.xml:
<hibernate-mapping>
<class name="OuterView" table="vw_user_basic_info" catalog="ideas">
<comment></comment>
<composite-id name="id" class="InnerView">
<key-property name="accUserId" type="long">
<column name="acc_user_id" />
</key-property>
<key-property name="accountId" type="long">
<column name="account_id" />
</key-property>
<key-property name="accUserType" type="long">
<column name="acc_user_type" />
</key-property>
<key-property name="accOwnerFlg" type="java.lang.Integer">
<column name="acc_owner_flg" />
</key-property>
<key-property name="firstName" type="string">
<column name="first_name" length="50" />
</key-property>
<key-property name="middleName" type="string">
<column name="middle_name" length="50" />
</key-property>
<key-property name="lastName" type="string">
<column name="last_name" length="50" />
</key-property>
<key-property name="accountName" type="string">
<column name="account_name" length="100" />
</key-property>
<key-property name="userName" type="string">
<column name="user_name" length="50" />
</key-property>
<key-property name="userPwd" type="string">
<column name="user_pwd" length="500" />
</key-property>
<key-property name="securityQuestion" type="string">
<column name="security_question" length="100" />
</key-property>
<key-property name="securityAnswer" type="string">
<column name="security_answer" length="100" />
</key-property>
<key-property name="forgetFlag" type="int">
<column name="forget_flag" />
</key-property>
<key-property name="salt" type="string">
<column name="salt" length="200" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>
OuterView.java:
public class OuterView implements java.io.Serializable
{
// Fields
private InnerView id;
// Constructors
/** default constructor */
public OuterView()
{
}
/** full constructor */
public OuterView(InnerView id)
{
this.id = id;
}
// Property accessors
public InnerView getId()
{
return this.id;
}
public void setId(InnerView id)
{
this.id = id;
}
}
InnerView.java:
public class InnerView implements java.io.Serializable
{
// Fields
private long accUserId;
private long accountId;
private long accUserType;
private Integer accOwnerFlg;
private
String firstName;
private String middleName;
private String lastName;
private String accountName;
private String userName;
private String userPwd;
private String securityQuestion;
private String securityAnswer;
private int forgetFlag;
private String salt;
// Constructors
/** default constructor */
public InnerView()
{
}
/** minimal constructor */
public InnerView(long accUserId, long accountId, long accUserType,
String firstName, String accountName, String userName,
String userPwd, String securityQuestion, String securityAnswer,
int forgetFlag, String salt)
{
this.accUserId = accUserId;
this.accountId = accountId;
this.accUserType = accUserType;
this.firstName = firstName;
this.accountName = accountName;
this.userName = userName;
this.userPwd = userPwd;
this.securityQuestion = securityQuestion;
this.securityAnswer = securityAnswer;
this.forgetFlag = forgetFlag;
this.salt = salt;
}
/** full constructor */
public InnerView(long accUserId, long accountId, long accUserType,
Integer accOwnerFlg, String firstName, String middleName,
String lastName, String accountName, String userName,
String userPwd, String securityQuestion, String securityAnswer,
int forgetFlag, String salt)
{
this.accUserId = accUserId;
this.accountId = accountId;
this.accUserType = accUserType;
this.accOwnerFlg = accOwnerFlg;
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.accountName = accountName;
this.userName = userName;
this.userPwd = userPwd;
this.securityQuestion = securityQuestion;
this.securityAnswer = securityAnswer;
this.forgetFlag = forgetFlag;
this.salt = salt;
}
// Property accessors
public long getAccUserId()
{
return this.accUserId;
}
public void setAccUserId(long accUserId)
{
this.accUserId = accUserId;
}
public long getAccountId()
{
return this.accountId;
}
public void setAccountId(long accountId)
{
this.accountId = accountId;
}
public long getAccUserType()
{
return this.accUserType;
}
public void setAccUserType(long accUserType)
{
this.accUserType = accUserType;
}
public Integer getAccOwnerFlg()
{
return this.accOwnerFlg;
}
public void setAccOwnerFlg(Integer accOwnerFlg)
{
this.accOwnerFlg = accOwnerFlg;
}
public String getFirstName()
{
return this.firstName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public String getMiddleName()
{
return this.middleName;
}
public void setMiddleName(String middleName)
{
this.middleName = middleName;
}
public String getLastName()
{
return this.lastName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getAccountName()
{
return this.accountName;
}
public void setAccountName(String accountName)
{
this.accountName = accountName;
}
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserPwd()
{
return this.userPwd;
}
public void setUserPwd(String userPwd)
{
this.userPwd = userPwd;
}
public String getSecurityQuestion()
{
return this.securityQuestion;
}
public void setSecurityQuestion(String securityQuestion)
{
this.securityQuestion = securityQuestion;
}
public String getSecurityAnswer()
{
return this.securityAnswer;
}
public void setSecurityAnswer(String securityAnswer)
{
this.securityAnswer = securityAnswer;
}
public int getForgetFlag()
{
return this.forgetFlag;
}
public void setForgetFlag(int forgetFlag)
{
this.forgetFlag = forgetFlag;
}
public String getSalt()
{
return this.salt;
}
public void setSalt(String salt)
{
this.salt = salt;
}
}
Hibernate Code:
Criteria criteria = session.createCriteria(VwUserBasicInfo.class);
List resultList = criteria.list();