[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Use an entity as a discriminator column
|
In general I would avoid using a mapped attribute as the discriminator, as
attribute value can change, but an object's class cannot. But I don't see
any reason why it wouldn't work, did you try it, what error do you get?
The discriminator value is just the column value, so integer id, 1, 2, 3,
etc.
You may need to make the JoinColumn as insertable/updateable=false.
bea-5 wrote:
>
> Hi,
>
> I have some entities with an joined inheritance type. In my root entity I
> have an attribute that is a @ManyToOne relationship to other table. In
> short, my entity looks like this:
>
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> @Table(name = "service")
> public class Service implements Serializable {
>
> @JoinColumn(name = "service_type_id", referencedColumnName = "id")
> @ManyToOne
> private ServiceType serviceTypeId;
> ....
>
> The attribute serviceTypeId is a foreign key to other entity:
>
> @Entity
> @Table(name = "service_type")
> public class TipoServicio implements Serializable {
>
> @Id
> @GeneratedValue(strategy = GenerationType.IDENTITY)
> @Basic(optional = false)
> @Column(name = "id")
> private Integer id;
>
> @Column(name = "name")
> private String name;
> ......
>
> I'd like to have as DiscriminatorColumn the field serviceTypeId, but I
> don't
> know how to do it, as that field hasn't a correct discriminatorType. Is
> there any way to do what I want?
>
> Thanks!
>
> --
> Beatriz Nombela Escobar
> beaotx@xxxxxxxxx
>
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://old.nabble.com/Use-an-entity-as-a-discriminator-column-tp26542136p26581349.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.