-
1. Re: Hibernate JPA example
chubutin Feb 7, 2014 3:29 PM (in response to objectiser)I don't have an example, but I can show you how I configure Hibernate with Mysql or SQL in many projects I have.
Install the features:
<feature>jpa</feature>
<feature>jpa-hibernate</feature>
Install the drivers
osgi:install mvn:mysql/mysql-connector-java/5.1.18
osgi:install wrap:mvn:com.microsoft.sqlserver/sqljdbc4/4.0
Import the drivers into your bundle
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
com.mysql.jdbc;resolution:=optional,
com.microsoft.sqlserver.jdbc;resolution:=optional,
org.hibernate;resolution:=optional,
org.hibernate.annotations;resolution:=optional,
org.hibernate.criterion;resolution:=optional,
javassist.util.proxy;resolution:=optional,
org.hibernate.proxy;resolution:=optional,
org.hibernate.dialect;resolution:=optional,
org.springframework.aop;resolution:=optional,
org.springframework.aop.framework;resolution:=optional,
org.aopalliance.aop;resolution:=optional,
javax.persistence.criteria;resolution:=optional,
javax.persistence.metamodel;resolution:=optional,
*;resolution:=optional,
</Import-Package>
<Bundle-Description>${project.description}</Bundle-Description>
<Export-Package>
</Export-Package>
</instructions>
</configuration>
</plugin>
And you can use Hibernate inside you service!
<!-- CONFIGURACION HIBERNATE JPA -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- enable the configuration of transactional behavior based on annotations -->
<!-- <tx:annotation-driven transaction-manager="transactionManager" /> -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.esb.entities</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernateDialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="cache.provider_class">{cache.provider_class}</prop>
<prop key="cache.use_query_cache">${cache.use_query_cache}</prop>
<prop key="cache.use_minimal_puts">${cache.use_minimal_puts}</prop>
<prop key="max_fetch_depth">${max_fetch_depth}</prop>
<!-- Print SQL to stdout. -->
<prop key="show_sql">${show_sql}</prop>
<prop key="format_sql">${format_sql}</prop>
</props>
</property>
</bean>
<!-- TEST DATASOURCE -->
<bean id="dataSource" class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<property name="URL" value="${urlDataSource}" />
<property name="user" value="${databaseUser}" />
<property name="password" value="${databasePassword}" />
</bean>
-
2. Re: Hibernate JPA example
davsclaus Feb 21, 2014 11:00 AM (in response to objectiser)A community users created this github project with a JPA Hibernate example on JBoss Fuse 6.1
-
3. Re: Hibernate JPA example
objectiser Feb 23, 2014 12:52 PM (in response to davsclaus)Thanks I'll check it out.