java - Hibernate Domain Object Generation -
i'm trying understand how best generate , synchronize domain model pojo's database using hibernate. right process managed build following:
- build er schema on database
- have hibernate.reveng.xml file containing elements (one each table)
- use jboss tools on eclipse run code generation configuration set target package , location, aforementioned reveng.xml file , generated pojo's, mapping files , hibernate.cfg.xml files
but has lot of problems:
- i cannot map common fields (id, created by, modified by, etc..) particular base entity.
- i have manage lot of mapping files (doesn't seem generate single one)
- i cannot generate basepojo , have extended 1 modifications on pojo's aren't overriden next code generation.
- i cannot fine tune output location of generated artifacts (mappings, .cfg , pojos) go same base folder (pojo's placed according package name set)
is possible "tell" generator map common table fields same classe (createdby, modifiedby, id, etc...) ?
i'm questioning if approach makes sense @ all? should managing pojo's hand ? don't mind managing mapping files (.hbm.xml) lot.
or should find way go "code first", ie. write pojo's , generate schema ? i'm bit used .net's entity framework , feel quite lost on what's "proper" way build persistence layer in java/hibernate
thank you
the telosys tools code generator solution you.
it uses existing database generate kind of source file each entity (database table), typically pojo, dto, dao, web pages, etc... when database schema change have regenerate.
for more information see web site : https://sites.google.com/site/telosystools/ , tutorials : https://sites.google.com/site/telosystutorial/
all templates free , customizable, hibernate pojo can use jpa templates (https://github.com/telosys-tools/persistence-jpa-tt210-r2) , adapt them if necessary
Comments
Post a Comment