Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

entity beans and multiple tables

 
jose nascimento
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mandrack, please check your private messages.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using EJB 2.1 Entity Beans? BMP or CMP?
 
jose nascimento
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn Verburg,

Yes it makes sense.

thanks again.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic