我正在使用 org.springframework.orm.hibernate4.LocalSessionFactoryBean.LocalSessionFactoryBean 并具有以下类:
@Entity
@Table(name="ORDERS")
public class Order implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private long id;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn
private Item item;
...
}
和
@Entity
@Table(name="ITEM")
public class Item implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private long id;
private String img;
private long price;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn
private ItemCategory category;
private String description;
...
}
但是当服务器启动时,对于 ORDERS 表,没有创建外键:
mysql> desc ORDERS;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| item | tinyblob | YES | | NULL | |
| placedDate | datetime | YES | | NULL | |
| quantity | int(11) | NO | | NULL | |
| status | varchar(255) | YES | | NULL | |
+------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)
有什么问题?请建议。
谢谢