I have two table,user table and book card table,like follows:
User table:
Code:
user_id varchar2(20);
user_name varchar2(20);
Book card table:
Code:
card_id varchar2(20);
user_id varchar2(20);
TableNode.java
Code:
Public class TableNode{
String user_id;
String user_name;
//set and get method
//...
}
BookCardNode.java
Code:
Public class BookCardNode{
String card_id;
String user_id;
//set and get method
//...
}
Then I make table mapping under Hibernate
User.hrb.xml
Code:
<hibernate-mapping>
<class name="UserNode" table="USER">
<property name="user_id" type="java.lang.String">
<column name="user_id" length="20" not-null="true" />
</property>
<property name="user_name" type="java.lang.String">
<column name="user_name" length="20" not-null="true" />
</property>
</class>
</hibernate-mapping>
BookCard.hrb.xml
Code:
<hibernate-mapping>
<class name="BookCardNode" table="BOOKCARD">
<property name="card_id" type="java.lang.String">
<column name="card_id" length="20" not-null="true" />
</property>
<property name="user_id" type="java.lang.String">
<column name="user_id" length="20" not-null="true" />
</property>
</class>
</hibernate-mapping>
I have two question:
Question 1: I want to make User.hrb.xml and BookCard.hrb.xml with one-to-one relationship,but I don’t know how to modify above User.hrb.xml and BookCard.hrb.xml?
Question 2:I have following data,
User table
Code:
User_id user_name
John SmithPeter
Kate Kate J.
Book Card table
Code:
Card_id user_id
1002 John
Then I query book card table,like following:
Code:
List info=this.getHibernateTemplate().find("from BookCardNode where and user_id=’John’)
I want to this result List contains such data: 1002 John SmithPeter
My question is how to write this.getHibernateTemplate().find(“?????"),and how to extract data from List?
Please give me detail statement,Thanks in advance!