• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Map 2 CMP Entity Beans to 1 table?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I'm working with a legacy database table that cannot be changed. I need to associate each DAY with a set of TIMES.

Here's the structure:

Table Name: DAY

day_id open_time close_time sequence
------ -------- ---------- --------
MONDAY 06:00 AM 08:00 PM 1
MONDAY 10:00 PM 10:30 PM 2
TUESDAY 06:00 AM 08:00 PM 1
WEDNESDAY 06:00 AM 07:00 PM 1
THURSDAY 06:00 AM 04:00 PM 1
THURSDAY 10:00 PM 10:30 PM 2

-The primary key is (day_id, sequence)

Here is what I have so far:

-I think there should be 2 entity beans (DayBean, TimeBean); DayBean has a Collection of TimeBeans
-There is a one-to-many relation from DayBean to TimeBean.

Has anyone else encountered a recursive table as such? Ideas?
 
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no expert, but if I were you I'd use one bean for the entire table, but have whatever structure is most logical in your value objects. Then, do the mapping in the getVO/setVO methods on your bean. I'd imagine it'll be much easier to do the mapping there.

You couldn't use CMR to do your daybean/timebean mapping, since (AFAIK) all CMR implementations require two tables with a foreign key-type attribute on one or both of them. It seems to me that the basic usual philosophy 'one entity bean maps onto one table'.

More on Sun's view of Value Objects is here, though I'm not sure that'll be of that much use.


-Tim
 
Russ R
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. I will most likely just use a Session Bean w/JDBC and populate 2 VO's as you suggest.

Any expert EJB designers with suggestions?

 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could give Sun's Java forums a go if no-one here is forthcoming.

And good ol' Mastering EJB2 book is available free on the 'net, though I'm not sure it'd be a huge amount of help in this situation.


-Tim
 
Russ R
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mastering EJB 2nd edition has a section on 'Dealing w/ Legacy data', but no suggestions for this particular table design.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't we use ejbSelectXXX method to get the TIMES details ? this method can return a collection of attributes of entity bean.
 
Russ R
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that is a very good suggestion.

Using selectXXX gives me the abililty to manage the relationships without using CMR.

thanks alot!
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic