例如 :学生 与课程之间是多对多关联,中间表不仅有学生表和课程表的主键,中间表还有其他字段(成绩等),该如何配置,用
JPA如何设置,望大家指点指点|
2条回答 默认 最新
- iteye_20011 2011-03-23 02:38关注
一个事例:
LoginInfo.hbm.xml
[code="xml"]
[/code]LoginInfo对象
[code="java"]
package com.ucit.ca.webApp.po;/**
- CasUserModuleInfo entity. @author MyEclipse Persistence Tools */
public class LoginInfo implements java.io.Serializable {
// Fields
private String lid;
private Uinfo uinfo;
private Module module;
private User user;// Constructors /** default constructor */ public LoginInfo() { } /** full constructor */ public LoginInfo(Uinfo uinfo, Module module, User user) { this.uinfo = uinfo; this.module = module; this.user = user; } // Property accessors public Uinfo getUinfo() { return uinfo; } public String getLid() { return lid; } public void setLid(String lid) { this.lid = lid; } public void setUinfo(Uinfo uinfo) { this.uinfo = uinfo; } public Module getModule() { return module; } public void setModule(Module module) { this.module = module; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } @Override public boolean equals(Object other) { if ((this == other)) return true; if ((other == null)) return false; if (!(other instanceof LoginInfo)) return false; LoginInfo castOther = (LoginInfo) other; return ((this.getUser() == castOther.getUser()) || (this.getUser() != null && castOther.getUser() != null && this.getUser().equals( castOther.getUser()))) && ((this.getUinfo() == castOther.getUinfo()) || (this .getUinfo() != null && castOther.getUinfo() != null && this.getUinfo() .equals(castOther.getUinfo()))) && ((this.getModule() == castOther.getModule()) || (this .getModule() != null && castOther.getModule() != null && this.getModule() .equals(castOther.getModule()))); } @Override public int hashCode() { return "com.ucit.ca.webApp.po.LoginInfo".hashCode(); }
}
[/code]具体字段再加就是了
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报