Posted In: Hibernate

Hibernate 5 – One to Many – @JoinColumn vs mappedBy

@JoinColumn Specifies a column for joining an entity association or element collection. If the JoinColumn annotation itself is defaulted, a single join column is assumed and the default values apply. mappedBy The field that owns the relationship. Required unless the relationship is unidirectional. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = “employer”) private Set employees […]

Read More

by , on September 4th, 2017

Posted In: Hibernate

Hibernate 5 – @GenericGenerator hilo_seqeunce

From Hibernate user guide hilo; legacy-hilo Define a custom algorithm for generating pools of values based on a single value from a table or sequence. These optimizers are not recommended for use. They are maintained (and mentioned) here simply for use by legacy applications that used these strategies previously. @GenericGenerator(name = “hilo_sequence_generator”, strategy = “org.hibernate.id.enhanced.SequenceStyleGenerator”, […]

Read More

by , on September 4th, 2017

Posted In: Apache Log4J, Hibernate, Logback, Logging, SLF4J

Hibernate 5 – print a query string with parameter values

Logging frameworks used 1. Using LOG4J slf4j-log4j12 2. Using LOGBACK 3. Using LOG4J 2X   1. Using LOG4J slf4j-log4j12 Maven slf4j-log4j12 log4j.properties Will print both BasicTypeRegistry and BasicBinder (parameter values) logs. log4j.logger.org.hibernate.type=ALL Will print only BasicBinder (parameter values) logs. log4j.logger.org.hibernate.type.descriptor.sql=trace Parameter values logs 12:52:11,376 TRACE BasicBinder:65 – binding parameter [1] as [VARCHAR] – [Abhijit] 12:52:11,376 […]

Read More

by , on September 4th, 2017

Posted In: Hibernate

Hibernate 5 – hbm2ddl.auto explained

Note – hbm2ddl.auto is a facility to do faster development and testing. This should not be used in production. hbm2ddl.auto has four options 1. validate 2. update 3. create4 4. create-drop Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the […]

Read More

by , on September 3rd, 2017

  • Categories