aspose file tools*
The moose likes Object Relational Mapping and the fly likes entity beans and multiple tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "entity beans and multiple tables" Watch "entity beans and multiple tables" New topic
Author

entity beans and multiple tables

jose nascimento
Greenhorn

Joined: Sep 18, 2008
Posts: 3
Hi guys,

I have already searching on this forum for something about that but found nothing. Maybe It's just a too noooooob question, but I hope someone could help me on this.

I would like to know if some one can help me understand one thing about beans and database tables.

OK,

I have one table and also have a bean that is representation of this table.

I do a select on that table and iterate through the result set creating a new bean for each iteration adding it to an ArrayList. Everything is just fine with that. Things work just like I think they should do.

The problem:
I have the same table, but now I need to do a sort of joins on it.

the question:
Do I have to build a new bean representing all this joins?

ps: I am not using hibernate or any other jpa implementation.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

mandrack, please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Are you using EJB 2.1 Entity Beans? BMP or CMP?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
jose nascimento
Greenhorn

Joined: Sep 18, 2008
Posts: 3
Hi Martijn Verburg ,

thanks for reply.

I am using Entity Beans.


I have totally understood using 1 bean x 1 table but things get confused to understand when I have to generate reports, for instance.

Thanks in advance.


regards,

J. Nascimento
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

What you are effectively doing is creating a 'view' for the data. I would recommend creating a Javabean that represents this view and use EJB QL to create and execute a query (whose results can be translated into the Javabean).

Hope that made sense!
jose nascimento
Greenhorn

Joined: Sep 18, 2008
Posts: 3
Hi Martijn Verburg,

Yes it makes sense.

thanks again.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I have one table and also have a bean that is representation of this table


To clarify, an Entity EJB is a temporary, object-oriented representation of a single record in a table, not the entire table.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: entity beans and multiple tables
 
Similar Threads
ojb newbie questions
Beginner Problem: son & parent
Slow Entity Beans
Mapping annotation -> one class per table question
Entity bean performance