-->
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 to set Entity in JPA --Beginner question---
PostPosted: Wed May 12, 2010 12:11 pm 
Newbie

Joined: Tue Nov 18, 2008 5:01 am
Posts: 11
Hi all
i want to build my DB with JPA. I have an inner class which is extended from Hashmap but i don't know how to set the annotations correctly:

I have following example for my issue:

It's a 1:n relation

Table Car:
id|anyContent1|anycontent2
-----------------------------
1|Porsche | 911
2|OPEL | Astra

Tabelle CarItem
id|key |value |car_Id
-----------------------
1|color |green|1
2|seats| 4 |1


I tried to set the following annotations in my sample classes but it seems to be wrong:


Code:
@Entity
public class Car{


   @Entity
   public class CarItems extends HashMap<String, String>{

      @OneToOne
      Car carObj = new Car();

      public Car getCar() {
         return carObj;
      }
      public void setCar(Car carObj) {
         this.carObj = carObj;
      }
               
      double priceOfAllItems;
      .....
   }



     @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   private int carId;


          public void setCarId(int carId) {
      this.carId = carId;
   }
   
   public int getCarId() {
      return carId;
   }


   @OneToOne(mappedBy="cdb")
        private Car_Items carItems;

   public CAData getCAR() {
      return caData;
   }

   public String getResultID() {
      return resultID;
   }

}


How should i set the annotations to get above table structure. The structure of the classes i can't change. i've an inner class which is inherited from HashMap....

thanks in advance
Max[/QUOTE]


Top
 Profile  
 
 Post subject: Re: How to set Entity in JPA --Beginner question---
PostPosted: Mon May 17, 2010 4:53 am 
Newbie

Joined: Tue Nov 18, 2008 5:01 am
Posts: 11
hi,

doesn't anyone have an idea? i think it could be solved with annotations but how?

any reply would be greatly appreciated

max


Top
 Profile  
 
 Post subject: Re: How to set Entity in JPA --Beginner question---
PostPosted: Mon May 17, 2010 11:16 am 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
look into Embeddable and Embedded annotation


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.