-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How map a collection of objects that consist of collection
PostPosted: Tue Apr 01, 2008 10:42 am 
Newbie

Joined: Fri Mar 21, 2008 4:09 am
Posts: 6
Location: Kyiv, Ukraine
I use hibernate-3.2, hibernate-annotations-3.3.1.CR1.

There are two classes.

First(BigBoard) can be independent of second(BoardList):

Code:
package board;

import java.util.Map;
import java.util.TreeMap;

import javax.persistence.*;

@Embeddable
@Entity
@Table(name = "BIGBOARDS")
public class BigBoard {
   
   @Id @GeneratedValue
   @Column(name = "BIGBOARD_ID")
   private Long id;

   @Column(name = "CITY")
   private   String city;

   @Column(name = "LOCATION")
   private String location;

        @org.hibernate.annotations.CollectionOfElements
   @JoinTable(
      name = "BIGBOARD_STATUS",
      joinColumns = @JoinColumn(name = "BIGBOARD_ID")
   )
   @Column(name = "STATUS", nullable = false)
   @org.hibernate.annotations.OrderBy(
      clause = "MONTH"   
   )
   @org.hibernate.annotations.MapKey(
      columns = @Column(name = "MONTH")   
   )
   private Map<String, String> status = new TreeMap<String, String>();
     
     //Constructor, accessor methods, equals()/hashCode()
             
}


This class has been mapped perfect:

Code:
alter table BIGBOARD_STATUS
     drop constraint FKF7B8706B92263A02;

     drop table BIGBOARDS if exists;

     drop table BIGBOARD_STATUS if exists;

create table BIGBOARDS (
         BIGBOARD_ID bigint generated by default as identity (start with 1),
         CITY varchar(255),
         LOCATION varchar(255),
         primary key (BIGBOARD_ID)
  );

create table BIGBOARD_STATUS (
         BIGBOARD_ID bigint not null,
         STATUS varchar(255) not null,
         MONTH varchar(255),
         primary key (BIGBOARD_ID, MONTH)
     );

    alter table BIGBOARD_STATUS
        add constraint FKF7B8706B92263A02
        foreign key (BIGBOARD_ID)
         references BIGBOARDS;


The second class:
Here I have tried a lot of different ways to tell Hibernate how it would save it.
Code:
package board;

import java.util.*;
import javax.persistence.*;

@Entity
@Table(name = "BOARDLISTS")
public class BoardList {
   
   @Id @GeneratedValue
   @Column(name = "BOARDLIST_ID")
   private Long id;
   
   @Column(name = "DATE")
   private Date date = new Date();
       
        //@What's here?   
   private SortedSet<BigBoard> bigBoardList = new TreeSet<BigBoard>();
        //Constructor, accessor methods, equals()/hashCode()
}


I've not got correct mapped BoardList.


I'd love get any advice. Thanks in advance.


Last edited by fes83 on Wed Apr 02, 2008 8:45 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 8:35 pm 
Newbie

Joined: Fri Mar 21, 2008 4:09 am
Posts: 6
Location: Kyiv, Ukraine
I've read a lot of docs and It seems impossible for Hibernate yet:(
Someone from Hibernate team, destroy my last doubts and hopes. Please, just tell me yes or no.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 05, 2008 3:57 pm 
Newbie

Joined: Fri Mar 21, 2008 4:09 am
Posts: 6
Location: Kyiv, Ukraine
I've resolved this problem. Thanks for silence.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.