-->
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: MongoDB - Read on generic property returns null
PostPosted: Tue Apr 05, 2016 4:02 am 
Newbie

Joined: Mon Apr 04, 2016 5:57 pm
Posts: 1
I am currently trying to use HibernateOGM 5.0.0 Beta with MongoDB.

In my application i store some kind of meta-objects, who own a Set of DBProperty-Objects (see below) to store its properties and values. To achieve this the DBProperty is a generic abstract class with a generic attribute called "value". For each type of property there is an implementing class.
All classes look the like the one below, only "Value" is of another type (i.e. String, Float, etc.) and are named accordingly.
Code:
@Entity
@DiscriminatorValue("L")
@XmlType
public class DBLongProperty extends DBProperty<Long> {

[...]
   @Basic
   @Override
   @XmlAttribute
   public Long getValue() {
      return super.getValue();
   }
[...]
}


The abstract class has a number of non overriden attributes (part of it inherited from further above in the hierarchy, such as an ID) who are read just finde.
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="Prop_Type")
public abstract class DBProperty<T> extends DBIdentified {
[...]

private T value;

   @Transient
   @XmlTransient
   public T getValue() {
      return this.value;
   }
[...]
}

When working with HibernateOGM everything is written correctly to the DB but when i try to read an Object (For both nativeQuery and JPQL) all attributes are read except for "value", which returns a NULL. I checked the DB, but the value is set correctly.
When reading a DBLongProperty(or any other implementing class) directly the returned object has the value set correctly.

Has anyone an idea, why this happens?

Kind regards


Top
 Profile  
 
 Post subject: Re: MongoDB - Read on generic property returns null
PostPosted: Thu Apr 07, 2016 10:44 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi,
how do you read the property, could you provide a small code example?

I suspect it is related to the
Code:
@Transient
you are using on the super class, but I haven't tested it yet.

Cheers,
Davide


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.