Announcement Announcement Module
No announcement yet.
Java To DB doesn't work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java To DB doesn't work

    I use Oracle Toplink (which support java2db). This works fine in one application without using Spring. When I create another app, using spring, and the same other JPA configuration, I don't get any exception when add an object to the database. However, when looking at the database, the tables are not created (also, query fails because the tables are not found).

    <property name="toplink.ddl-generation" value="drop-and-create-tables"/>

    Was in the properties in the persistent.xml file.

    Does Spring support this? If so, how? Thanks.

  • #2
    It has nothing to do with Spring it is a Toplink issue and probably something in your configuration.


    • #3
      It's good to hear. So, what possibly could be the problem here?
      After putting @Repository, I now get the exception for it, but all it says is that the tables are not found when I add an object.

      The method I use is:

      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
      <property name="dataSource" ref="someDataSource"/>
      <property name="persistenceXmlLocation" value="classpathersistence.xml" />
      <property name="loadTimeWeaver">
      <bean class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver"/>

      Which means the J2EE container doesn't load the JPA, but Spring will take care of it (because the location of persistence file is changed).

      I also have the following (besides the data source):

      <bean class=" enceAnnotationBeanPostProcessor"/>
      <bean class="org.springframework.dao.annotation.Persiste nceExceptionTranslationPostProcessor"/>

      One strange note is that in J2ee app, my persistence.xml doesn't require me to specify each entity class. Here, I have to do that (if not, it won't be found).


      • #4
        Please use [ code][/code] tags when posting code/configuration.

        Can you also post the contents of your persistence.xml?

        You might also try setting a JpaVendorAdapter explicitly...
        Last edited by Marten Deinum; Nov 15th, 2007, 04:29 PM.


        • #5
          By adding the jpaVendorAdapter property and point it to Oracle toplink, it works.

          My persistent.xml file is:

          <?xml version="1.0" encoding="UTF-8"?>
          <persistence version="1.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
            <persistence-unit name="PersistentAppPU" transaction-type="JTA"   >
                <property name="hibernate.show_sql" value="true"/>
                <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
          There are possible 2 bugs in Spring here. First, it doesn't follow the settings here (that I had to explicitly set the oracle toplink). Second, I didn't have to specify the "SomeClass" before, now, I have to.