hibernate多对一单向关联

阅读更多

一、创建是实体类

 

package com.wr.hibernate.entity;

public class Custom {

	private int customId;
	private String customName;

	public int getCustomId() {
		return customId;
	}

	public void setCustomId(int customId) {
		this.customId = customId;
	}

	public String getCustomName() {
		return customName;
	}

	public void setCustomName(String customName) {
		this.customName = customName;
	}

	public Custom(int customId, String customName) {
		super();
		this.customId = customId;
		this.customName = customName;
	}

	public Custom() {
		super();
		// TODO Auto-generated constructor stub
	}

	@Override
	public String toString() {
		return "Custom [customId=" + customId + ", customName=" + customName + "]";
	}

}

 

package com.wr.hibernate.entity;

public class Order {

	private int orderId;
	private String orderName;
	private Custom custom;

	public Custom getCustom() {
		return custom;
	}

	public void setCustom(Custom custom) {
		this.custom = custom;
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getOrderName() {
		return orderName;
	}

	public void setOrderName(String orderName) {
		this.orderName = orderName;
	}

	@Override
	public String toString() {
		return "Order [orderId=" + orderId + ", orderName=" + orderName + ", custom=" + custom + "]";
	}

}

 

 

二、添加POJO配置文件

 






	

		
			
			
			
		

		
			
		

	


 






	

		
			
			
			
		

		
			
		
		
		
		
			
		
		
	


 

 

 

你可能感兴趣的:(hibernate,java,orm)