Hi Wouter,
I am reading the glassfish example
(
https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html)
and it fits with your explaining.
On the other hand, your explaining completes
questions that I need for my web.
Thanks a lot,
Pepe Álvarez de Lara
--------------------------------------------------
From: "Wouter van Reeven" <wouter_at_van.reeven.nl>
Sent: Wednesday, February 18, 2009 5:35 PM
To: <persistence_at_glassfish.dev.java.net>
Subject: Re: Entities and Relations in MySQL DB
> Hi,
>
> On Wed, Feb 18, 2009 at 05:25:26PM +0100, Pepe Álvarez de Lara wrote:
>> #1.- Do I need an Entity for any table in the DB?
>
> If you would like to be able to insert, update or delete any data in any
> table
> using JPa then yes. Technically you can do the same thing with native
> queries or
> with stored procedures but I wouldn't call that JPA. Any table that you
> don't
> want to insert, update or delete data from you don't need as an Entity.
>
>> #2.- On first time I am going to do only select queries, but exists a
>> relationship type of many-to-many between tables in the DB I solved
>> with normalization. How do I indicate this relationship in the code?
>
> That depends. If your intersection table only contains two columns (one id
> for
> the first and one id for the secodn table) then a ManyToMany relation
> would do.
> In case you have more columns then you'll need two OneToMany relations.
>
>> #3.- I do not use keyGen to generate the PKs. All of them are type of
>> auto-increment.
>> Is this problematic?
>
> AFAIK no. But I have no experience with MySQL autoincrement columns.
>
>> #4.-Do I need an Entity for everyone relation table?
>
> See my answer to question #2. If you need two OneToMany relations then
> you'll
> need an Entity for the relation table.
>
>
> HTH, Wouter van Reeven
>
> --
> There are 10 kinds of people in the world. Those that understand
> the binary system and those that don't.
> [Unknown Source]
>