-->
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.  [ 5 posts ] 
Author Message
 Post subject: New 'entities' at runtime
PostPosted: Wed Dec 17, 2014 3:19 pm 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Hi all,
Does OGM support adding new document types (new entities) during runtime, such that they are defined during runtime then available for searching without a restart?

Usecase: Given a parent object, PetOwner, who has a list of Pets. There may be specific pet types with additional fields (Dog with breed field), but over time new pets may be added that also need additional fields (MicroPig with weight field that wasn't available in other pets, just as a random example). Attempting to find tooling that would easily support runtime definition of new entity/types and the associated data storage.

-D


Top
 Profile  
 
 Post subject: Re: New 'entities' at runtime
PostPosted: Thu Dec 18, 2014 6:54 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
We don't quite have plans for what you describe. It would require Hibernate ORM to accept new entities at runtime as well. Which can be discussed.
Your problem adds an additional twist because you would want to add classes on an existing hierarchy - that requires existing structures to be made mutable.

But we are thinking of the ability to expose unmapped properties. Check out https://hibernate.atlassian.net/browse/OGM-470

Code:
{
    # common to all products
    "_id" : "1234-5678-0123-4567",
    "name": "Binford 2000",
    "description": "High performance lawnmover",
    "price": "799.99",

    # specific to category/type etc.
    "engine power": "20 PS",
    "color": "Red",
    "Cut height": "100"
}
This could be mapped to a Product entity like this:
@Entity
public class Product {

    @Id
    private long id;
    private String name;
    private double description;
    private BigDecimal price;

    @AdditionalProperties
    private Map<String, Object> additionalProperties;

    // ...
}

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: New 'entities' at runtime
PostPosted: Thu Dec 18, 2014 6:55 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
And I forgot the question.
Would that be good enough, do you really need dynamic entities added at runtime?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: New 'entities' at runtime
PostPosted: Thu Dec 18, 2014 9:31 am 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Thanks for the quick response!

For my usecase, having an additional properties field would fit well, since majority of time the usecases we have is there will always be a base entity type.

will vote for ticket, and add comment about possible search/sorting options either through JPA-QL or example usage.

Thanks again, this would absolutely work for my usecase.
-D


Top
 Profile  
 
 Post subject: Re: New 'entities' at runtime
PostPosted: Thu Dec 18, 2014 10:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Ah indeed JP-QL support should be considered for the additional properties.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.