Announcement Announcement Module
No announcement yet.
Spring Data REST - Connecting for example to a mssql db config. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data REST - Connecting for example to a mssql db config.

    I am trying to alter the Spring Data REST demo project to point to an actual database, but it is not working.

    So far I have tried the following changes, but I think I am lacking something.


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""

    <jdbc:embedded-database id="dataSource" type="HSQL"/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
    <property name="generateDdl" value="true"/>
    <property name="database" value="SQL_SERVER"/>
    <property name="persistenceUnitName" value="jpa.mssql"/>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>



    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="" version="2.0">
    <persistence-unit name="jpa.sample">
    <class> n</class>
    <class> le</class>
    <class> ss</class>
    <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
    <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:spring"/>
    <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
    <property name="hibernate.connection.username" value="sa"/>
    <property name="hibernate.connection.password" value=""/>
    <property name="" value="create-drop"/>

    <persistence-unit name="jpa.mssql">
    <class> n</class>
    <class> le</class>
    <class> ss</class>
    <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect"/>
    <property name="hibernate.connection.url" value="jdbc:sqlserver://localhost:1433"/>
    <property name="hibernate.connection.driver_class" value=" r"/>
    <property name="hibernate.connection.username" value="sa"/>
    <property name="hibernate.connection.password" value="asdasd123"/>
    <!-- property name="" value="create-drop"/ -->


    I cannot seem to understand why the entityManagerFactory specifies a dataSource if that information is also inside the persistence file. I don't know how to change that part.

    This config wont start up and the logs don't really say what the problem is. It just says fail fail fail on everything it tries but does not give any reasons why its fails.

    Please help.

  • #2
    Aah, never mind.

    I just had to remove the dataSource setting in the entityManagerFactory and include the sqljdbc file in the INF/Lib folder.

    Everything works, this stuff is amazing. So much functionality for almost no effort.