tushar
tushar

Reputation: 75

JPA-Mapping problem

Reference(http://stackoverflow.com/questions/4688709/problem-in-jpa-mapping)

I have a situation where my DB tables are like below, I am wondering how to have JPA mappings for this kind of tables , espacially for the auction_param_values which do not have primary key ID

Table Name : auction with primary key as auction_id

Table Name : *auction_param* with primary key as auction_param_id

Table AUCTIO_PARAM is used stores the details of parameters such as Start_Date,End_Date etc.

auction_param_id | auction_param_desc 

1                | start date
2                | end_date 

Table Name : auction_param_values

It stores the actual values of that parameters related to Auction.

Table looks like:-

auction_id | auction_param_id | auction_param value | 

   1       |      2           |      2011-01-15     | 

How will the entity class look for the auction_param_values ? is there any pointer on how we can design the schema to support JPA (we are using Eclipselink as a provider).

If require I can provide more details.

Upvotes: 2

Views: 184

Answers (1)

James
James

Reputation: 18379

You schema seems a little overly fragmented, but maybe it is more complex then you are showing.

Your model depends on your design, but you could have something like,

Auction
@Id
long id;
@OneToMany
List<ParameterValue> parameterValues;

ParameterValue
@Id
@ManyToOne
Auction auction;
@Id
@ManyToOne
Parameter parameter;
@Basic
String value;

Parameter
@Id
long id;
@Basic
String description
@Basic
Date startDate;
@Basic
Date endDate;

Upvotes: 1

Related Questions