Java Reference
In-Depth Information
A typical implementation of a bag mapping is as follows:
<bag name="bag" table="namebag">
<key column="fooid"/>
<element column="value" type="string" not-null="true"/>
</bag>
Mapping Simple Classes
Figure 7-1 shows the class diagram and entity relationship diagram for a simple class. They are
as straightforward as you would expect.
Figure 7-1. Representing a simple class
The elements discussed so far are sufficient to map a basic class into a single table, as
shown in Listing 7-3.
Listing 7-3. A Simple Class to Represent a User
package com.hibernatebook.xmlmapping;
public class User {
public User(String username) {
this.username = username;
}
User() {
}
public int getId() {
return id;
}
public String getUsername() {
return username;
}
Search WWH ::




Custom Search