Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Mapping a Database View



ljnelson wrote:
> 
>    1. Create an @Embeddable class that has these three fields in it.  This
>    will end up being your Java class's composite primary key class.
>    2. Mark each of those fields with the appropriate @Column annotation.
>    For example, one of your composite key member variables might be
>    "businessID", in which case your @Column annotation would be
> @Column(name =
>    "busId").
>    3. Override its equals() and hashCode() methods so that two instances
> of
>    this class are equal if and only if all three fields have equal values.
>    4. With that done, go back to your main .java file and give it a field
>    called, say, ID or PK or something similar.  Mark that field as being
> its
>    @EmbeddedId.  Its type should be the type of the embeddable class you
> just
>    created.
>    5. Map that .java file using the @Table annotation to your view.
> 

So ... in exactly the same way that I would model a database table that has
a composite key? That's basically what I meant by "faking" it. Thanks again
for evryone's help.

Regards

-- 
View this message in context: http://www.nabble.com/Mapping-a-Database-View-tp25401383p25402876.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top