java - subsets in spring/hibernate entity mappings -


in spring/hibernate, best way handle subsets of data need used in different situations?

i have spring mvc app using hibernate create interface massive database in mysql millions of rows per table. of jsp views in app interact given subset of perhaps 100,000 of rows in given table might have 10,000,000 rows in total. want view retrieve data quickly, tried creating new database table 100,000 rows, matched new entity map new database table. lead complicated code. better way speed improvements of working subset of data?

here have far:

@entity @table(name = "conc_dual_key") public class concdualkey {      @id     @column(name="dualkey")     private string name;      @manytomany(cascade = {cascadetype.all})//     @jointable(name="conc_dual_key_junction_new",         joincolumns={@joincolumn(name="dualkey")},         inversejoincolumns={             @joincolumn(name = "conceptid", referencedcolumnname="id", insertable = false, updatable = false),             @joincolumn(name="effectivetime", referencedcolumnname="effectivetime", insertable = false, updatable = false)})     private set<concept> concepts = new hashset<concept>();      //getters , setters }  

i made copy of entity different table mappings in database, new tables created contain subset data:

@entity @table(name = "conc_finding_dual_key") public class concfindingdualkey {      @id     @column(name="dualkey")     private string name;      @manytomany(cascade = {cascadetype.all})//     @jointable(name="conc_finding_dual_key_junction_new",         joincolumns={@joincolumn(name="dualkey")},         inversejoincolumns={             @joincolumn(name = "conceptid", referencedcolumnname="id", insertable = false, updatable = false),             @joincolumn(name="effectivetime", referencedcolumnname="effectivetime", insertable = false, updatable = false)})     private set<concept> concepts = new hashset<concept>();      //getters , setters }  

don't duplicate reuse same entity combine annotations xml mapping specify table. retrieve use name gave entity instead of class.

<entity-mappings         xmlns="http://java.sun.com/xml/ns/persistence/orm"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://java.sun.com/xml/ns/persistence/orm         http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"                  version="2.0">      <entity name="concdualkey" class="concdualkey" table="conc_dual_key" />     <entity name="concfindingdualkey " class="concdualkey" table="conc_finding_dual_key" />  </entity-mappings> 

something this. make concfindingdualkey read-only.

the mappings go in file called orm.xml file should reside in meta-inf directory of project. (that default location specified in jpa specification, can put anywhere have explicitly tell hibernate find file including mapping-file element in persistence.xml).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -