-->
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: Hibernate ManyToOne mapping with filter
PostPosted: Fri Apr 22, 2016 2:43 am 
Newbie

Joined: Fri Apr 22, 2016 2:40 am
Posts: 1
I have two tables like below. First one is a general parameter table. Second table is the server data table.
Code:
    PARAMETER
    ID CODE       VALUE  DESCRIPTION
    1  PLATFORM   1      Core
    2  PLATFORM   2      Remote
    3  ENVRNMNT   1      Dev

    SERVER
    ID   NAME     PLATFORM
    1    serv1    1
    2    serv2    2

**SERVER.PLATFORM** column references **PARAMETER.VALUE** column, only for **PARAMETER.CODE = 'PLATFORM'**. Is there a way to implement Filter on a ManyToOne relation? Is there a way to make this work for example:
Code:
    @Table(name="PARAMETER", schema = "PRM")
    public class Parameter implements Serializable{
   
       @Id
      @GeneratedValue(strategy = IDENTITY)
      @Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)   
      private String id;

       @Column(name = "CODE", length = 30)
       private String code;

      @Column(name = "VALUE", length = 30)
      private String value;
   
       @Column(name = "DESCRIPTION", length = 30)
       private String description;
    }

    @Table(name="SERVER", schema = "PRM")
    public class Server implements Serializable{
   
       @Id
      @GeneratedValue(strategy = IDENTITY)
      @Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)   
      private String id;

       @Column(name = "NAME", length = 30)
       private String name;

       @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
      @JoinColumn(name="PLATFORM", referencedColumnName="VALUE")
       @Filter(name = "parameter_platform", condition = "CODE='PLATFORM'")
       private Parameter platform;
    }


Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate ManyToOne mapping with filter
PostPosted: Fri Apr 22, 2016 4:06 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It might be a regression, can you add a Jira issue with a replicating test case.


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.