Announcement Announcement Module
Collapse
No announcement yet.
PK member is not of specified type (javax.jdo.identity.LongIdentity) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PK member is not of specified type (javax.jdo.identity.LongIdentity)

    Hello All,

    I'm using:

    spring-framework 3.1.0
    datanucleus 3.0.5
    spring-data-jpa 1.0.2

    My simple entity is this:

    Code:
    package net.jufis.domain;
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    @Entity
    @Table(name = "PATTERN")
    public class Pattern implements DomainObject {
    	private static final long serialVersionUID = -4394080632194051131L;
    	@Id
    	@Column(name="ID")
    	private Long id;
    
    	@Column(name = "TOP")
    	private Integer top;
    
    	@Column(name = "BOTTOM")
    	private Integer bottom;
    
    	@Column(name = "LEFT")
    	private Integer left;
    
    	@Column(name = "RIGHT")
    	private Integer right;
    
    	public Pattern() {
    		super();
    	}
    
    	public Long getId() {
    		return id;
    	}
    
    	public void setId(Long id) {
    		this.id = id;
    	}
    
    	public Integer getTop() {
    		return top;
    	}
    
    	public void setTop(Integer top) {
    		this.top = top;
    	}
    
    	public Integer getBottom() {
    		return bottom;
    	}
    
    	public void setBottom(Integer bottom) {
    		this.bottom = bottom;
    	}
    
    	public Integer getLeft() {
    		return left;
    	}
    
    	public void setLeft(Integer left) {
    		this.left = left;
    	}
    
    	public Integer getRight() {
    		return right;
    	}
    
    	public void setRight(Integer right) {
    		this.right = right;
    	}
    }
    and my persistence.xml is this:

    Code:
    	<persistence-unit name="jDataServiceUnit" transaction-type="RESOURCE_LOCAL">
    		<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
    		<class>net.jufis.domain.Pattern</class>
    		<exclude-unlisted-classes>true</exclude-unlisted-classes>
    		<properties>
    			<property name="datanucleus.ConnectionDriverName" value="org.h2.Driver" />
    			<property name="datanucleus.ConnectionURL" value="jdbc:h2:tcp://localhost/c:/dev/db/jufisdb" />
    			<property name="datanucleus.ConnectionUserName" value="sa" />
    			<property name="datanucleus.ConnectionPassword" value="" />
    			<property name="datanucleus.autoCreateSchema" value="true" />
    			<property name="datanucleus.validateTables" value="false" />
    			<property name="datanucleus.validateConstraints" value="false" />
    			<property name="datanucleus.jpa.addClassTransformer" value="false"/>
    
    			<property name="datanucleus.connectionPoolingType" value="C3P0" />
    			<property name="datanucleus.connectionPool.minPoolSize" value="5" />
    			<property name="datanucleus.connectionPool.initialPoolSize" value="5" />
    			<property name="datanucleus.connectionPool.maxPoolSize" value="20" />
    			<property name="datanucleus.connectionPool.maxStatements" value="50" />
    		</properties>
    	</persistence-unit>
    </persistence>

    my spring repository interface is this:

    Code:
    package net.jufis.dao;
    
    import net.jufis.domain.Pattern;
    
    import org.springframework.data.jpa.repository.JpaRepository;
    
    public interface PatternRepository  extends JpaRepository<Pattern, Long> {
    
    }
    my dao impl:

    Code:
    package net.jufis.dao;
    
    import java.util.List;
    
    import net.jufis.domain.Pattern;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.data.domain.Page;
    import org.springframework.data.domain.Pageable;
    import org.springframework.data.domain.Sort;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public class PatternDaoImpl extends BaseDaoImpl implements PatternDao {
    
    	@Autowired
    	private PatternRepository patternRepository;
    	
    	@Override
    	public void deleteInBatch(Iterable<Pattern> patterns) {
    		patternRepository.deleteInBatch(patterns);
    	}
    
    	@Override
    	public List<Pattern> findAll() {
    		return patternRepository.findAll();
    	}
    
    	@Override
    	public List<Pattern> findAll(Sort sort) {
    		return patternRepository.findAll(sort);
    	}
    
    	@Override
    	public void flush() {
    		patternRepository.flush();
    	}
    
    	@Override
    	public List<Pattern> save(Iterable<? extends Pattern> patterns) {
    		return patternRepository.save(patterns);
    	}
    
    	@Override
    	public Pattern saveAndFlush(Pattern pattern) {
    		return patternRepository.saveAndFlush(pattern);
    	}
    
    	@Override
    	public Page<Pattern> findAll(Pageable pageable) {
    		return patternRepository.findAll(pageable);
    	}
    
    	@Override
    	public long count() {
    		return patternRepository.count();
    	}
    
    	@Override
    	public void delete(Long id) {
    		patternRepository.delete(id);
    	}
    
    	@Override
    	public void delete(Pattern pattern) {
    		patternRepository.delete(pattern);
    	}
    
    	@Override
    	public void delete(Iterable<? extends Pattern> patterns) {
    		patternRepository.delete(patterns);
    	}
    
    	@Override
    	public void deleteAll() {
    		patternRepository.deleteAll();
    	}
    
    	@Override
    	public boolean exists(Long id) {
    		return patternRepository.exists(id);
    	}
    
    	@Override
    	public Pattern findOne(Long id) {
    		return patternRepository.findOne(id);
    	}
    
    	@Override
    	public Pattern save(Pattern pattern) {
    		return patternRepository.save(pattern);
    	}
    }
    my dao interface:


    Code:
    package net.jufis.dao;
    
    
    public interface PatternDao extends PatternRepository {
    
    }
    and the spring config:

    Code:
    <beans ...>
    
    	<tx:annotation-driven />
    
    	<context:component-scan base-package="net.jufis"/>
    	<jpa:repositories base-package="net.jufis"/>
    
    	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    	<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
    
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="jDataServiceUnit" />
    	</bean>
    
    	<bean class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
    
    	
    	<bean id="patternDao" class="net.jufis.dao.PatternDaoImpl"/>
    	
    </beans>
    When I run my unit test I always get the following exception:

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'patternRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: PK member is not of specified type (javax.jdo.identity.LongIdentity). Should be java.lang.Long
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1441)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    	... 43 more
    Caused by: java.lang.IllegalArgumentException: PK member is not of specified type (javax.jdo.identity.LongIdentity). Should be java.lang.Long
    	at org.datanucleus.api.jpa.metamodel.IdentifiableTypeImpl.getId(IdentifiableTypeImpl.java:74)
    	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:58)
    	at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:61)
    	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145)
    	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:83)
    	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:66)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:131)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:114)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:38)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
    	... 51 more

    The big question initialy is if datanucleous is cooperating with spring-data-jpa 1.0.2 RELEASE.

    I found on the datanucleous byte code enhancment of my domain object that the LongIdentity class is used all over the place which is something internal that I shouldn't worry about.

    My question is simple is spring-data-jpa officially supported for datanucleous, if so which versions? Am I doing something wrong here?

    You help is very much appreciated,

    Kind Regards,
    jufis
Working...
X