public class Mail {
@Id
@GeneratedValue
private long id;
@Column(length=50, nullable=false)
private String title;
@Column(length=3000, nullable=false)
private String content;
@Column(length=30, nullable=false)
private String time;
@OneToOne
private User sender;
@ManyToMany(mappedBy="mails")
private HashSet<User> toUsers;
//..............
public class User {
@Id
@GeneratedValue
private long id;
@Column(length=20, nullable=false)
private String name;
@Column(length=20, nullable=false)
private String password;
@Column(length=2, nullable=false)
private String sex;
private Map<Mail, Integer> mails;//这个map怎么写?
上面是邮件类与用户类,两者进行关联。把ger set都省掉了。
那个map映射生成的表应该要是:
user_id---------mail_id(key)---------state(value)
*这个state是邮件的状态,在邮件类中并没有这个字段。
@Id
@GeneratedValue
private long id;
@Column(length=50, nullable=false)
private String title;
@Column(length=3000, nullable=false)
private String content;
@Column(length=30, nullable=false)
private String time;
@OneToOne
private User sender;
@ManyToMany(mappedBy="mails")
private HashSet<User> toUsers;
//..............
public class User {
@Id
@GeneratedValue
private long id;
@Column(length=20, nullable=false)
private String name;
@Column(length=20, nullable=false)
private String password;
@Column(length=2, nullable=false)
private String sex;
private Map<Mail, Integer> mails;//这个map怎么写?
上面是邮件类与用户类,两者进行关联。把ger set都省掉了。
那个map映射生成的表应该要是:
user_id---------mail_id(key)---------state(value)
*这个state是邮件的状态,在邮件类中并没有这个字段。
解决方案 »
- oh
- 我用JAVA中的框架mybatis框架时找不到对象
- 个人对 hibernate 的一点愚见。
- TOMCAT和APACHE集群问题
- 请教LINUX如何设置防火墙,允许特定IP或者IP段进行访问,屏蔽其他IP
- 非常急的问题,<html:text 里死活从action bean里取不出值来,我要疯了~~~
- 这样的递归有什么问题吗?
- 一个jbuilderx里中文乱码的问题??
- 请问一下在j2ee开发中,什么时候用到ejb,什么时候用到javabean啊,还有jms在j2ee中有什么作用!大家能讨论一下吗!:)
- 现有需求:两个关联表A,B。当A中插入一条记录时,在B中插入多条记录,同时将A中的主键插入B中,如果B中插入操作失败时,A表回滚。在EJB
- 论坛里这么这么多办zheng件的
- 一个struts1 hiberate问题
<map name="">
<map-key type="" column="">
</map>
根据这个 我想注解应该能猜出来。做做实验吧。