How to automatically generate Java code and hbm xml files using eclipse tools
1. Create hibernate.cfg.xml and hibernate.reveng.xml using wizard.
2. Use Hibernate Code Generation under the eclipse Run menu to create a new configuration using the prior two files and create code/xml/schema
3. Resulted test code need the Apache common logging jar to compile
- Hibernate can access fields directly without getters and setters ?
- All persistent entity classes need an identifier property
- All persistent classes need no constructor argument
- The DTD file is in hibernate-core.jar
- GetCurrentSession always return the current unit of work
- A Session is a wrapper for a JDBC connection
- pool_size specifies the JDBC connection pool size – not meant for production
- Use non-final classes for lazy loading
- Optimistic Lock Schemes:
- version: default, recommended
- none: do not use
- dirty: check column changed
- all: check all columns
- identity – native means either identity or sequence.
- Trying to assign value to native identity column causes cannot insert error
- @Version annotation adds optimistic locking capability
- StaleObjectStateException if row is updated
- To make version work with timestamp Sybase datatype, make sure to prevent update by setting version to Generated: always