hibernate - Storing and retrieving copmosit objects in Java -


i have more 2 classes have approximately 7 same fields , following in java part:

public abstract class ibase {    private string commonfield1;    private string commonfield2;    private string commonfield3;    private emytype type; // type of object: my_type_1 or my_type_2    // ...     // + constructor , getters/setters }  public class baseimpl1 extends ibase {    private int base1specific1;    private int base1specific2;    // ...     // + constructor , getters/setters }  public class baseimpl2 extends ibase {    private int base2specific;    private string base2specific2;     // ...     // + constructor , getters/setters } 

i have 2 questions:

  1. what best way reflect 2 object within database?
  2. how should retrieve them via hibernate?

using morphia, you'd mark interface @entity(somecollectionname). when you're querying types, have datastore.createquery(baseimpl1.class).filter("classname = ", baseimpl1.class.getname()) retrieve particular subclass.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -