为什么不可以呢?create table CUSTOMERS (
ID bigint not null,
NAME varchar(15),
AGE int,
primary key (ID)
);create table IMAGES(
CUSTOMER_ID bigint not null,
FILENAME varchar(15) not null,
primary key (CUSTOMER_ID,FILENAME)
);alter table IMAGES add index IDX_CUSTOMER(CUSTOMER_ID), add constraint FK_CUSTOMER foreign key (CUSTOMER_ID) references CUSTOMERS(ID);<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false"> <class name="collection.set.Customer" table="CUSTOMERS" >
<id name="id" type="long" column="ID">
<generator class="increment"/>
</id>
<property name="name" type="string" >
<column name="NAME" length="15" />
</property>
<property name="age" type="int" >
<column name="AGE" />
</property>
<set name="images" table="IMAGES" lazy="true" >
<key column="CUSTOMER_ID" />
<element column="FILENAME" type="string" not-null="true"/>
</set>
</class>
</hibernate-mapping>package collection.set;import java.io.Serializable;
import java.util.Set;
import java.util.TreeSet;public class Customer implements Serializable {
private Long id;
private String name;
private int age;
private Set images=new TreeSet(); /** full constructor */
public Customer(String name, int age,Set images) {
this.name = name;
this.age=age;
this.images = images;
} /** default constructor */
public Customer() {
} /** minimal constructor */
public Customer(Set images) {
this.images = images;
} public Long getId() {
return this.id;
} public void setId(Long id) {
this.id = id;
} public String getName() {
return this.name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return this.age;
} public void setAge(int age) {
this.age = age;
} public Set getImages() {
return this.images;
} public void setImages(Set images) {
this.images = images;
}}
ID bigint not null,
NAME varchar(15),
AGE int,
primary key (ID)
);create table IMAGES(
CUSTOMER_ID bigint not null,
FILENAME varchar(15) not null,
primary key (CUSTOMER_ID,FILENAME)
);alter table IMAGES add index IDX_CUSTOMER(CUSTOMER_ID), add constraint FK_CUSTOMER foreign key (CUSTOMER_ID) references CUSTOMERS(ID);<?xml version="1.0" encoding="GBK" ?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false"> <class name="collection.set.Customer" table="CUSTOMERS" >
<id name="id" type="long" column="ID">
<generator class="increment"/>
</id>
<property name="name" type="string" >
<column name="NAME" length="15" />
</property>
<property name="age" type="int" >
<column name="AGE" />
</property>
<set name="images" table="IMAGES" lazy="true" >
<key column="CUSTOMER_ID" />
<element column="FILENAME" type="string" not-null="true"/>
</set>
</class>
</hibernate-mapping>package collection.set;import java.io.Serializable;
import java.util.Set;
import java.util.TreeSet;public class Customer implements Serializable {
private Long id;
private String name;
private int age;
private Set images=new TreeSet(); /** full constructor */
public Customer(String name, int age,Set images) {
this.name = name;
this.age=age;
this.images = images;
} /** default constructor */
public Customer() {
} /** minimal constructor */
public Customer(Set images) {
this.images = images;
} public Long getId() {
return this.id;
} public void setId(Long id) {
this.id = id;
} public String getName() {
return this.name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return this.age;
} public void setAge(int age) {
this.age = age;
} public Set getImages() {
return this.images;
} public void setImages(Set images) {
this.images = images;
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货