java - Conditionally sort results in hibernate -


here tables i'm working with. there user table has predefined columns ('name' in example below) , attributes table used making schema extension possible. attributes table stores values new extended attributes key-value pairs('title' , 'mobile' attributes in example below) , 'user' column used joining main user table. arrangement works operations, not able think of way sort on of attributes users.

user table: --------------- id        name ==============  1         jon   2         harry   attributes table: -------------------------------- user   attr_key    attr_value ================================ 1      title       engineer 1      mobile      111-2222-4444 2      title       manager 2      mobile      111-0000-5555   result of joining 2 tables above(few columns intentionally skipped): -------------------------------------------- id        name     attr_key    attr_value ============================================ 1         jon      title       engineer 1         jon      mobile      111-2222-4444 2         harry    title       manager 2         harry    mobile      111-0000-5555 

i'm using hibernate orm. here entity classes:

@entity public class user {      private long id;     private string name;     private set<extraattributes> extraattributes;      public string getname() {}      @onetomany(mappedby="user",fetch=fetchtype.eager)     public set<extraattributes> getextraattributes() {}      ...  }  @entity public class extraattribute {      private long id;     private string attrkey;     private string attrvalue;     private user user;      ...      @manytoone(optional = false)     public user getuser() {}      ... } 

i want able sort results attr_value corresponding specific attr_key, 'title'. problem if order results attr_value attr_values considered, while want order attr_values correspond specific attr_key - 'title'. thought of ordering both attr_key attr_value doesn't seem solve problem either.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -