-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @ManyToAny without discriminator column
PostPosted: Thu Aug 10, 2017 8:32 am 
Newbie

Joined: Thu Aug 03, 2017 9:25 am
Posts: 6
Hello,
I am working on Kodo to Hibernate migration in a legacy system.
I have the following code structure:

Code:
@Entity
@DiscriminatorValue(value = "S")
public class StructuredDataParameter extends Parameter {
    private NFStructuredDataObject dataObject;
...
}

public interface NFStructuredDataObject {
...
}

public abstract class NFStructuredDataObjectAbstractImpl implements NFStructuredDataObject {
...
}


NFStructuredDataObjectAbstractImpl is extended by multiple entity classes.

Currently using Kodo (JDO), the field dataObject was stored in database in PARAMETER table in DATA_OBJECT column as string value:
Code:
com.xyz.data.ChildrenData:com.xyz.data.ChildrenData-175829

where 175829 is an example primary key in table CHILDREN_DATA and com.xyz.data.ChildrenData is an entity class that extends NFStructuredDataObjectAbstractImpl
Kodo did it by default. How can I achieve such behavior in Hibernate?
I thought about @ManyToAny with @JoinFormula but it needs an additional discriminator column. Maybe there's a way to implement custom UserType that will resolve the target class and ID based on parts of the string value?
I need to use Hibernate 4.2.18 and since the schema is legacy I shouldn't change it.


Top
 Profile  
 
 Post subject: Re: ManyToAny without discriminator column
PostPosted: Sun Aug 13, 2017 2:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can also use SINGLE_TABLE entity inheritance with the help of @DiscriminatorColumn.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.