Solving hibernate native SQL mapping problems

Source: Internet
Author: User

In the FAQ and forum, you often see questions about how to map the results of a local SQL query to a value object, and here's a conclusion on the methods provided in Hibernate. As a prerequisite, there is no deferred loading technique using attributes.

Suppose there is a value pair, as follows:

Java code

package test;
public class Person {
private Long ID;
private String name;
Private Long age;
Private Long phone;
Private String address;     

Public person (long ID, string name, long, long phone, String address) { = ID; = name;
This.age = age; = phone;
This.address = address;   

Public Long getId () {
return ID;

public void setId (Long id) { = ID;

Public String getName () {
return name;

public void SetName (String name) { = name;

Public Long getage () {
return age;

public void Setage (Long) {
This.age = age;

Public Long getphone () {
return phone;

public void Setphone (Long phone) { = phone;

Public String getaddress () {
return address;

public void setaddress (String address) {
This.address = address;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.