Ok last try , I tried it your way and that worked for me as well
here is the mapping:
Code:
<class name="A" table="tb_A">
<id name="kip" column="kip" type="java.lang.String">
<generator class="assigned">
</generator>
</id>
<list name="bs" lazy="false" cascade="none">
<key column="kip"></key>
<index column="id" />
<one-to-many class="B" />
</list>
</class>
Code:
<class name="B">
<id name="id" column="id" type="int">
<generator class="native">
</generator>
</id>
<property name="kip" type="java.lang.String" update="false"
column="kip" />
</class>
My configuration file:
Code:
<session-factory>
<!-- properties -->
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
org.gjt.mm.mysql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">
123
</property>
<property name="show_sql">true</property>
<property name="hibernate.cglib.use_reflection_optimizer">
false
</property>
<property name="hibernate.connection.autocommit">true</property>
<mapping resource="A.hbm.xml" />
<mapping resource="B.hbm.xml" />
</session-factory>
and the Java code:
Code:
public class A {
public String kip;
public List bs = new ArrayList();
public String getKip() {
return kip;
}
public void setKip(String kip) {
this.kip = kip;
}
public List getBs() {
return bs;
}
public void setBs(List bs) {
this.bs = bs;
}
}
Code:
public class B {
private int Id;
private String kip;
public int getId() {
return Id;
}
public void setId(int id) {
Id = id;
}
public String getKip() {
return kip;
}
public void setKip(String kip) {
this.kip = kip;
}
}
I tried it, the Sessionfactory started witout any problem I was able to insert new A´s B´s and get the collection with a Criteria