hibernate - What do these JPA annotations mean? -


could please explain these annotaions mean in plain "human" language. don't want documentation, want hear tattr table joined tinstit table primary key institid , constraint follows , on. sql language ok :) i'm bit confused. thanks

i've mapping class

    @entity     @discriminatorvalue("individual")     @secondarytable(schema = "dbo", name="tattr", pkjoincolumns = {@primarykeyjoincolumn(name = "institid")})     public class faindividual extends faclient  

and extends this:

@entity public abstract class faclient extends fainstit 

and above extends

@entity @immutable @inheritance(strategy = inheritancetype.single_table) @discriminatorformula(     "case "         + "when ((insttype = 0) , (propdeal = 0)) 'individual' "         + "when ((insttype = 0) , (propdeal = 1)) 'legal' "         + "when (insttype = 1) 'bank' "         + "when (insttype = 2) 'subdivision' "     + "end" ) @table(schema = "dbo", name = "tinstit") @jsontypeinfo(use = jsontypeinfo.id.class, include = jsontypeinfo.as.property, property = "@class") public abstract class fainstit 

your classes fainstit (<--extends) faclient (<-- extends) faindividual annotated @entity means these persistent classes fields mapping db tables/columns.

in super class fainstit have nominated entities in inheritance hierarchy share same primary table - dbo.tinstit – annotation @inheritance(strategy = inheritancetype.single_table)

when using single table entities, need identify each record in table belonging 1 or other of classes. done @discriminatorcolumn (a default column name chosen if skip annotation). value placed in discriminatorcolumn can specified @discriminatorvalue annotation. whenever persist faindividual, value in discriminatorcolumn individual.

it case require entity map more 1 table. primary table in example dbo.tinstit may define number of secondary tables @secondarytable annotation. have done in faindividual , should see in definition of class (not shown) fields of class map either of tables. row of secondary table used defined join information in @secondarytable attribute;

pkjoincolumns = {@primarykeyjoincolumn(name = "institid")} 

so have join where dbo.tinstit.id = dbo.tattr.institid, , jpa update/read etc entity fields across 2 tables according join information.

you have stated

i don't want documentation

but i’m afraid need there lot learn here. suggest digging out few tutorials/examples covering sort of ground.

i hope gets going.


Comments