Pageable support for Spring Data JPA having jndi look up for entityManagerFactory - spring-data-jpa

I was following http://terasolunaorg.github.io/guideline/1.0.x/en/ArchitectureInDetail/Pagination.html to implement Pagination support for my MVC application
When I try to start the JBoss Server,
nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List com.repo.MyRepository.searchEntitySC(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.Date,java.lang.String,java.util.Date,java.lang.String,java.lang.String,java.lang.String,org.springframework.data.domain.Pageable)!
Reason: Your persistence provider does not support extracting the JPQL query from a named query thus you can't use Pageable inside your query method. Make sure you have a JpaDialect configured at your EntityManagerFactoryBean as this affects discovering the concrete persistence provider.
I tried to follow, http://forum.spring.io/forum/spring-projects/data/99613-you-cannot-use-pageable-as-method-parameter-if-your-persistence-provider-cannot-extra
But I don't know how to apply the suggested configuration for entityManagerFactory
as my jpa-config.xml contains
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:jboss/pu/pc" />
Any other better suggestion is more than welcome!
Environment:
JBoss Enterprise Application Platform - Version 6.2.0.GA
spring-data-jpa-1.4.3.RELEASE.jar
hibernate-jpa-2.0-api-1.0.1.Final-redhat-2.jar
standalone.xml contains:
<datasource jndi-name="java:jboss/datasources/pc" pool-name="pcdatapool" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:#localhost:1521:mysid</connection-url>
<driver>oracle</driver>
<security>
<user-name>XXX</user-name>
<password>xxx</password>
</security>
</datasource>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="pcem">
<jta-data-source>java:jboss/datasources/pc</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>xxx.YYYYY</class>
...
<class>yyyy.AAAAAAAAAA</class>
<properties>
<property name="hibernate.jdbc.batch_size" value="50" />
<property name="hibernate.default_batch_fetch_size" value="50" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!-- Use log category 'org.hibernate.SQL' to level 'debug' to output SQL from hibernate -->
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false"/>
<!-- Use generate statistics this will help query performance tunning -->
<property name="hibernate.generate_statistics" value="false"/>
</properties>
</persistence-unit>

In the standalone.xml file remove the prefix java:. Then in persistence config file reference the jndi name you have in your standalone.xml but with the prefix. So:
persistence.xml
<jee:jndi-lookup id="myDatasource" jndi-name="java:jboss/datasources/pc" />
<mapping-file>META-INF/announcement-queries.hbm.xml</mapping-file>
jboss.datasource.xml
<datasource jndi-name="jboss/datasources/pc" pool-name="pcdatapool" enabled="true" use-ccm="false">
...
</datasource>
applicationContext.xml (Spring)
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="myDatasource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="false" />
<property name="showSql" value="${hibernate.show_sql}" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.use_sql_comments">${hibernate.format_sql}</prop>
<prop key="hibernate.connection.isolation">1</prop>
<prop key="hibernate.configurationClass">org.hibernate.cfg.AnnotationConfiguration</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.default_batch_fetch_size">100</prop>
<prop key="hibernate.id.new_generator_mappings">true</prop>
</props>
</property>
<property name="packagesToScan" value="com.mypacjage" />
</bean>

Related

How to integrate Apache Ignite with Cassandra as third party persistence?

I tried out below configurations but I get ClassNotFoundException for org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory. I am using docker image of apache ignite to achieve the same and its version is 2.9.1.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
<!-- Tune on Read-Through and Write-Through mode -->
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<!-- Specifying CacheStoreFactory -->
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
<!-- Datasource configuration bean which is responsible for Cassandra connection details -->
<property name="dataSourceBean" value="cassandraDataSource"/>
<!-- Persistent settings bean which is responsible for the details of how objects will be persisted to Cassandra -->
<property name="persistenceSettingsBean" value="primitive_csndra_cache"/>
</bean>
</property>
</bean>
</list>
</property>
</bean>
<bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
<constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
<bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
</constructor-arg>
</bean>
<bean id="cassandraAdminDataSource"
class="org.apache.ignite.cache.store.cassandra.datasource.DataSource">
<property name="port" value="9042" />
<property name="contactPoints" value="mycassandra.default.svc.cluster.local" />
<property name="readConsistency" value="ONE" />
<property name="writeConsistency" value="ONE" />
<property name="loadBalancingPolicy" ref="loadBalancingPolicy" />
</bean>
<bean id="primitive_csndra_cache" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
<constructor-arg type="java.lang.String">
<value><![CDATA[
<persistence keyspace="hello" table="primitive_xyz">
<keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="key"/>
<valuePersistence class="java.lang.String" strategy="PRIMITIVE" column="value"/>
</persistence>]]>
</value>
</constructor-arg>
</bean>
</beans>
Can anyone help me out on this? Any sort of sample github project or blog reference will also work out for me.
Take a look at these docs: https://ignite.apache.org/docs/latest/extensions-and-integrations/cassandra/configuration
and examples: https://ignite.apache.org/docs/latest/extensions-and-integrations/cassandra/usage-examples
overview: https://ignite.apache.org/docs/latest/extensions-and-integrations/cassandra/overview

Issue with JPA in JBoss Fuse 6.2

I am trying to implement a JPA application in JBoss Fuse 6.2. The attached files are the pom.xml, blueprint.xml and persistence.xml. They are working fine in JBoss Fuse 6.1. But we are always getting the error "No providers available" in 6.2 and the deployment is going in "waiting" stage.
I believe the problem is with the "jpa" feature. In 6.2, when I do "features:info jpa", it shows hibernate's bundle as the jpa unit ( mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0.Final), whereas in 6.1, it was the geronimo jpa bundle (mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1). I believe that is causing OpenJPA to fail since OpenJPA is compliant with JPA 2.0 but not 2.1. Please guide on how to solve this problem. I have tried not to use the jpa feature and rather use the bundles of the jpa feature from 6.1 version but it did not help either.
pom.xml
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric.version}</version>
<configuration>
<profile>org-profile</profile>
<parentProfiles>feature-cxf</parentProfiles>
<features>fabric-cxf swagger cxf-jaxrs transaction jndi jpa camel-spring spring-orm spring-jdbc
</features>
<featureRepos>
mvn:org.apache.cxf.karaf/apache-cxf/${version:cxf}/xml/features
mvn:org.apache.camel.karaf/apache-camel/${version:camel}/xml/features
</featureRepos>
<bundles>
mvn:mysql/mysql-connector-java/5.1.34
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.4_3
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.serp/1.14.1_1
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections/3.2.1_3
mvn:org.apache.openjpa/openjpa/2.3.0
</bundles>
</configuration>
</plugin>
blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
>
<jaxrs:server id="organizationService" address="/common">
<jaxrs:serviceBeans>
<ref component-id="organizationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:features>
<bean class="org.apache.cxf.jaxrs.swagger.SwaggerFeature"/>
</jaxrs:features>
</jaxrs:server>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://127.0.0.1:3306/test"/>
<property name="username" value="user"/>
<property name="password" value="pwd"/>
</bean>
<service ref="dataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/DataSource"/>
</service-properties>
</service>
<bean id="defOrganizationService" class="org.OrganizationDataServiceImpl">
<jpa:context unitname="PERSON"/>
<tx:transaction method="*" value="Required"/>
</bean>
<bean id="defOrgchartService" class="org.OrgchartDataServiceImpl">
<jpa:context unitname="PERSON"/>
<tx:transaction method="*" value="Required"/>
</bean>
<bean id="organizationServiceBean" class="org.OrganizationService">
<property name="organizationDataService" ref="defOrganizationService"/>
<property name="orgchartDataService" ref="defOrgchartService"/>
</bean>
</blueprint>
persistence.xml
<persistence-unit name="PERSON" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/DataSource)</jta-data-source>
<!-- this is very important -->
<class>org.Person</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- Schema update -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<!-- Specify dialect -->
<property name="openjpa.jdbc.DBDictionary" value="mysql"/>
<property name="openjpa.Log" value="File=C:/install/jboss-fuse-6.1.0.redhat-379/data/log/org.apache.openjpa.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
</properties>
</persistence-unit>
</persistence>

Tables for entities with boolean fields not created

i tried to switch a connection pool in GlassFish 4 from MySQL to Derby. I am using Spring-Data-JPA with JPA/Hibernate. The problem is that not all tables are created with the derby pool. The tables for entities which have at least one boolean field are not created.
I found nothing in the log files. :(
My applicationContext.xml:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:annotation-config />
<context:component-scan base-package="project" />
<bean
id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property
name="jndiName"
value="serverPool" />
<property
name="lookupOnStartup"
value="false" />
<property
name="proxyInterface"
value="javax.sql.DataSource" />
</bean>
<bean
id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property
name="generateDdl"
value="true" />
<property
name="showSql"
value="true" />
</bean>
<bean
id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property
name="dataSource"
ref="dataSource" />
<property
name="jpaVendorAdapter"
ref="hibernateJpaVendorAdapter" />
<property
name="packagesToScan"
value="project.model.entity" />
</bean>
<bean
id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property
name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<jpa:repositories base-package="project.model.repository" />
</beans>
If the problem is only creating boolean columns, try to use #Column to add DDL statement to the Derby database, I know this decrease portability but it will solve the problem. the property is named columnDefinition. http://docs.oracle.com/javaee/6/api/javax/persistence/Column.html
Also I think there need to be something in the log, try to increase the log level.
Okay, i found the solution: I connected to the derby database and executed the command values syscs_util.syscs_get_database_property( 'DataDictionaryVersion' ); The result was 10.1, but version 10.7 is necessary for boolean support. I then renamed the database name in the derby pool inside GlassFish (its by default sun-appserv-samples) and now all tables are created. With the new database the command gave me version 10.9.

not able to call restfull services

I am learning restfull , I have downloaded and deployed the example from following url.
http://fruzenshtein.com/spring-jpa-data-hibernate-mysql/ U can download source from git hub in page link
I have deployed and its deployed without an error.
When i am calling this restfull it is showing 404. I am using following url to call service.
http://127.0.0.1:8080/dpr-data/shop/create
Am i doing some thing wrong.
Can any body look into this example . I have moved spring configuration from java class to xml .
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.spr.controller" />
<context:component-scan base-package="com.spr.exception" />
<context:component-scan base-package="com.spr.init" />
<context:component-scan base-package="com.spr.model" />
<context:component-scan base-package="com.spr.repository" />
<context:component-scan base-package="com.spr.service" />
<context:component-scan base-package="com.spr.validation" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="persistenceUnitName" value="medical-unit" />
<property name="persistenceXmlLocation" value="/WEB-INF/persistence.xml" />
<property name="jpaProperties">
<props>
<prop key="dss.hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="dss.hibernate.generate_statistics">false</prop>
<prop key="dss.hibernate.cache.use_structured_entries">true</prop>
<prop key="dss.hibernate.show_sql">true</prop>
<prop key="dss.hibernate.format_sql">true</prop>
<prop key="dss.hibernate.jdbc.batch_size">50</prop>
<prop key="dss.hibernate.connection.username">root</prop>
<prop key="dss.hibernate.connection.password">root</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://127.0.0.1:3306/medicalstore" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver" >
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
</bean>
<!-- Data Source Declaration
<bean id="commonBasePooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
</bean>-->
Deploy works perfectly and controller is getting initiated , I am have put one log in #postconstructor methos and log is printing. But i am not able to get result from this service.
Having looked at the example, I noticed that the final name defined for the project in the POM is:
<finalName>dpr-data</finalName>
Note, starts with a 'd', not 's'.
This will result in the war file dpr-data.war and will be deployed to the context root dpr-data. This means you should access the service using the following URL:
http://127.0.0.1:8080/dpr-data/shop/create

Using Spring data JPA with MS SQL server

I am setting up an app using Spring data JPA, Hibernate and MS SQL Server and unfortunately, I got a beat messed up with the configurations.
I hope someone here code make things clearer:.
This is my mvc-dispatcher.xml which is the application context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:component-scan base-package="com.yyy.yyy" />
<context:property-placeholder location="classpath:db.properties"/>
<!-- DATA BASE -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="SQL_SERVER" />
</bean>
</property>
<property name="persistenceUnitName" value="punit" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClass}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.user}" />
<property name="password" value="${jdbc.pwd}" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<jpa:repositories base-package="com.yyy.yyy.yyy.repository"/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
Now, I also have a persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="punit">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.connection.url" value="${jdbc.url}" />
<property name="hibernate.connection.driver_class" value="${jdbc.driverClass}" />
<property name="hibernate.connection.username" value="${jdbc.user}" />
<property name="hibernate.connection.password" value="${jdbc.pwd}" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
</persistence>
I don't understand where should I put the DB connection data?
And I also cant connect to the DB (I get connection refused) - I am getting exception at server startup.
My project runs on Tomcat and I used https://github.com/SpringSource/spring-data-jpa-examples as a template.
EDIT
I managed to overcome the problems and publish to tomcat successfully,by removing the persistence XML file and use only the spring context file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="yyy.yyy.yyy" />
<context:property-placeholder location="classpath:db.properties" />
<!-- DATA BASE -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="yyy.yyy.yyy.yyy.domain" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="false" />
<property name="showSql" value="true" />
<property name="database" value="SQL_SERVER" />
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
</bean>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<property name="url" value="jdbc:jtds:sqlserver://localhost;databaseName=db" />
<property name="username" value="yyy" />
<property name="password" value="yyyyy" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<jpa:repositories base-package="yyy.yyy.yyy.yyy.repository" />
<!-- MVC -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
The app now loads fine, but when I use my repository and call save, I get connection refused exception.
Anyone knows why?
Help please.
Idob
You are refering to db.properites file here:<context:property-placeholder location="classpath:db.properties"/>
Where is it located in the project?