-->
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: Desiding the type of an Entity Attribute at runtime
PostPosted: Sat Nov 18, 2017 3:31 pm 
Newbie

Joined: Thu Nov 13, 2014 8:49 am
Posts: 9
I am using MongoDB and Hibernate OGM in my project.

My question is in the entity class (ExampleClass) I should be able to assign "someFeature" attribute a value at runtime that is an instance of either LabelClass or PointClass (i.e. an instance extended from Feature class based on some event). Is this possible if so can a example provided?

Lets say I have the following embeddable and the entity classes.

@Embeddable
@Inheritance(...)
public abstract class Feature{
@Id
protected Long id;



}

@Embeddable
public class LabelClass extends Feature{
protected String str;


}


@Embeddable
public class PointClass extends Feature{
protected Integer intg;


}

@Entity
public class ExampleClass{
private Feature someFeature;


}


Top
 Profile  
 
 Post subject: Re: Desiding the type of an Entity Attribute at runtime
PostPosted: Tue Nov 21, 2017 1:48 pm 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Sorry, at the moment I don't think there is a way to do that with OGM.
Inheritance with embeddables is not supported.

You might try to create your own TypeContributor implementation but it can be a bit complicated.


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.