garz wrote:
i'm not sure if you have already understood the way Hibernate works. in Hibernate you don't map tables, in Hibernate you map classes. this means you will need two class for the two tables of yours:
Code:
class KEYFRAME {
private Long id; <- use a Long as id, best solution, it has more size than the Integer
private String frame;
private Long video;
// getter and setter for the properties
}
class KEYFRAMEMATCHING {
private Long id;
private KEYFRAME keyframe1;
private KEYFRAME keyframe2;
private Integer similarity;
// getter and setter for the properties
}
the next step is you need mapping files for the classes... this is not difficult. best option is to buy a book and learn from it. i'm using "Hibernate in Action". things are nicely explained there. you should really try and learn how to do it by yourself.
thanks for your reply.
KeyFrameMatching have two primary keys -> keyframe1 and keyframe2. These attributes are even foreign key of KeyFrame table.
Now I must mapping these two classes (not in annotation mode) but I don't know how.
In "hibernate in action" my "case" similar to figure 3.11 at page 109 -> ITEM and BID but instead of having one PK and one FK, I have two PK that are the same of FK (for example BID_ID and ITEM_ID are two PK and FK of BID tables that refer themselves to ITEM_ID of ITEM table).
So I don't know
how can I solve and how map must I do (mapping files for the class)...
Code:
public class KeyFrame extends DomainObject {
private static final long serialVersionUID = 1L;
private String frame;
private Video video = new Video();
private Set<KeyFrame> keyframes = new HashSet<KeyFrame>();
...
Code:
public class KeyFrameMatching extends DomainObject {
private static final long serialVersionUID = 1L;
private int similarity;
private KeyFrame keyframe1;
private KeyFrame keyframe2;
...