Blog Archives

10: Spring, JavaConfig (i.e @Configuration), JPA & Hibernate by example

Example #1 Wiring JDBC Datasource application.yml where the datasource properties are read from. Example #2 Wiring JDBC Datasource with JNDI Example #3 Wiring the JPA persistence unit processors Callback interface for post-processing a JPA PersistenceUnitInfo. … Read more ›...



Spring loading property files & properties

conf/db.properties

# jdbc.X
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://localhost/mytestdb
jdbc.user=SA
jdbc.pass=
# hibernate.X
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=

#1. Register a Properties File in Application Context XML

The “<property-placeholder>” tag.

OR

#2.

Read more ›



Spring, JavaConfig (@Configuration), and TransactionManager

This extedns configuring JDBC and JPA to configure the TransactionManager.

Example #1 Wiring JDBC Transaction Manager

Note: @EnableTransactionManagement annotation

If you want to create a mock transaction manager, then you can do

Also,

Read more ›



Spring, JavaConfig (i.e @Configuration) & JDBC by example

Example #1 Wiring JDBC Datasource application.yml where the datasource properties are read. Example #2 Wiring JDBC Datasource with JNDI Example #3 Wiring JDBC Embedded Datasource for integration testing Example #4 Wiring up the JdbcTemplate by passing in the datasource Example #5 Wiring up a DAO class that uses the JdbcTemplate...



Spring, JavaConfig (i.e @Configuration) & JMS by example

Step 1: Define the messaging system connectivity, destination (e.g. topic or queue) and message selector properties via a YAML or .properties file. Here is an example of application.yml file. Step 2: MQTopicConnectionFactory The Java based Spring configuration defining the connection factory. Step 3: Destination The Java based Spring configuration defining...



800+ Java Q&As & tutorials

Top