hibernate single entity cascade query

巴扎黑
Release: 2016-12-20 14:20:27
Original
1269 people have browsed it

In fact, the usage of one-to-many and many-to-one of a single entity is the same as that of 2 entities. Now take user as an example:

java code:

package com.test.bean;

import java .util.Set;

public class User
{
private Integer id;
private String firstname;
private String lastname;
private Integer parentID;
private int age;
private Set childrens;
private User user;

public Set getChildrens() {
return childrens;
}

public void setChildrens(Set childrens) {
this.childrens = childrens;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public Integer getId()
{
return id;
}

public void setId(Integer id)
{
this.id = id;
}

public String getFirstname()
{
return firstname;
}

public void setFirstname(String firstname)
{
this.firstname = firstname;
}

public String getLastname()
{
return lastname;
}

public void setLastname(String lastname)
{
this.lastname = lastname;
}

public int getAge()
{
return age;
}

public void setAge(int age)
{
this.age = age;
}

public Integer getParentID() {
return parentID;
}

public void setParentID(Integer parentID) {
this.parentID = parentID;
}

}


Corresponding hbm file:


"http://hibernate .sourceforge.net/hibernate-mapping-3.0.dtd">





length="50">

length="50 ">

lazy="false" where=" age=4">









Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!