Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Toplink 11g extensions with Spring & JPA

455640Nov 12 2007 — edited Nov 24 2007
Hi,

Im currently trying to use Spring/JPA with some TopLink 11g extensions for Conversion but are unable to get this working.
I have tried a lot of different converters but it seems like all my TopLink annotations are ignored.

I would really appriciate all help I can get on this.

Iv included a small "dummy" below.

When using the converter on the class below I was hoping that the generated schema would be like:

CREATE TABLE TYPECONVTEST (ID NUMERIC(19) NOT NULL, AGE VARCHAR2(255), PRIMARY KEY (ID))

But the generated schema is:

CREATE TABLE TYPECONVTEST (ID NUMERIC(19) NOT NULL, AGE INTEGER, PRIMARY KEY (ID))

Dummy example:

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;

import oracle.toplink.annotations.Convert;
import oracle.toplink.annotations.TypeConverter;

@Entity
@TypeConverter(name = "intToString", dataType = String.class, objectType = Integer.class)
public class TypeConvTest implements Serializable {

@Id
private long id;

@Convert("intToString")
int age;

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public int getAge() {
return this.age;
}

public void setAge(int age) {
this.age = age;
}
}

My Spring configuration is like this:

.
.
.

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:test" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>

<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.OracleTopLinkJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform" value="oracle.toplink.platform.database.HSQLPlatform" />
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="jpaProperties">
<props>
<prop key="toplink.weaving">static</prop>
<prop key="toplink.logging.level">FINE</prop>
<prop key="toplink.ddl-generation">create-tables</prop>
<prop key="toplink.ddl-generation.output-mode">both</prop>
<prop key="toplink.drop-ddl-jdbc-file-name">generated_jpa.sql</prop>
<!-- <prop key="toplink.session.customizer">com.statoil.sas.invpilot.converter.ConverterCustomizer</prop>-->
</props>
</property>
</bean>

</beans>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2007
Added on Nov 12 2007
6 comments
2,058 views