java - Could not instantiate collection persister with JPA -


now development 1 multi-tenant system, use spring-boot jpa , hibernate.

there problem when want persister 1 collection. @ code, there have 1 embeddable class 'account', , @ tenant class, have 1 set<account>

tenant

@entity @table(name = "tenant",     uniqueconstraints = @uniqueconstraint(columnnames = "tenant_id")) public class tenant extends concurrentsafeentity<tenant, tenantid> {     private static final long serialversionuid = 6910165036330125453l;      @embeddedid     private tenantid tenantid;      @column(length = 20, nullable = false)     private string name;      @elementcollection     @collectiontable(name = "tenant_account")     private set<account> accounts;     ... } 

account

@embeddable public class account implements valueobject<account> {     private static final long serialversionuid = -2780296854441642870l;      @embedded     private accountnumber accountnumber;      @embedded     private encryptedpassword password;     ... } 

accountnumber

@embeddable public class accountnumber implements valueobject<accountnumber> {     private static final long serialversionuid = -2737145407283086518l;      @column(name = "account_number", nullable = false, updatable = false)     private string source;      @column(name = "type", nullable = false, updatable = false)     private string type;     ... } 

but when test by

@test public void constructor() throws exception {     tenant tenant = new tenant(             tenantrepository.nextidentity(), "aname",             new accountnumber("test@wcscent.com", "email"),             new encryptedpassword("apassword", encryptionservice),             validator     );      tenantrepository.save(tenant); } 

error is

java.lang.illegalstateexception: failed load applicationcontext  @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontext(defaultcacheawarecontextloaderdelegate.java:124) @ org.springframework.test.context.support.defaulttestcontext.getapplicationcontext(defaulttestcontext.java:83) @ org.springframework.test.context.web.servlettestexecutionlistener.setuprequestcontextifnecessary(servlettestexecutionlistener.java:189) @ org.springframework.test.context.web.servlettestexecutionlistener.preparetestinstance(servlettestexecutionlistener.java:131) @ org.springframework.test.context.testcontextmanager.preparetestinstance(testcontextmanager.java:230) @ org.springframework.test.context.junit4.springjunit4classrunner.createtest(springjunit4classrunner.java:228) @ org.springframework.test.context.junit4.springjunit4classrunner$1.runreflectivecall(springjunit4classrunner.java:287) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.springframework.test.context.junit4.springjunit4classrunner.methodblock(springjunit4classrunner.java:289) @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:247) @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:94) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61) @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:70) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:191) @ org.junit.runner.junitcore.run(junitcore.java:137) @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:68) @ com.intellij.rt.execution.junit.ideatestrunner$repeater.startrunnerwithargs(ideatestrunner.java:47) @ com.intellij.rt.execution.junit.junitstarter.preparestreamsandstart(junitstarter.java:242) @ com.intellij.rt.execution.junit.junitstarter.main(junitstarter.java:70)  caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaautoconfiguration.class]: invocation of init method failed; nested exception javax.persistence.persistenceexception: [persistenceunit: default] unable build hibernate sessionfactory @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1628) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:555) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:483) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197) @ org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext.java:1078) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:857) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:543) @ org.springframework.boot.springapplication.refresh(springapplication.java:693) @ org.springframework.boot.springapplication.refreshcontext(springapplication.java:360) @ org.springframework.boot.springapplication.run(springapplication.java:303) @ org.springframework.boot.test.context.springbootcontextloader.loadcontext(springbootcontextloader.java:120) @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontextinternal(defaultcacheawarecontextloaderdelegate.java:98) @ org.springframework.test.context.cache.defaultcacheawarecontextloaderdelegate.loadcontext(defaultcacheawarecontextloaderdelegate.java:116) ... 24 more  caused by: javax.persistence.persistenceexception: [persistenceunit: default] unable build hibernate sessionfactory @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.persistenceexception(entitymanagerfactorybuilderimpl.java:954) @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl.java:882) @ org.springframework.orm.jpa.vendor.springhibernatejpapersistenceprovider.createcontainerentitymanagerfactory(springhibernatejpapersistenceprovider.java:60) @ org.springframework.orm.jpa.localcontainerentitymanagerfactorybean.createnativeentitymanagerfactory(localcontainerentitymanagerfactorybean.java:353) @ org.springframework.orm.jpa.abstractentitymanagerfactorybean.buildnativeentitymanagerfactory(abstractentitymanagerfactorybean.java:370) @ org.springframework.orm.jpa.abstractentitymanagerfactorybean.afterpropertiesset(abstractentitymanagerfactorybean.java:359) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1687) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1624) ... 39 more caused by: org.hibernate.mappingexception: not instantiate collection persister org.hibernate.persister.collection.basiccollectionpersister @ org.hibernate.persister.internal.persisterfactoryimpl.createcollectionpersister(persisterfactoryimpl.java:167) @ org.hibernate.persister.internal.persisterfactoryimpl.createcollectionpersister(persisterfactoryimpl.java:140) @ org.hibernate.internal.sessionfactoryimpl.<init>(sessionfactoryimpl.java:399) @ org.hibernate.boot.internal.sessionfactorybuilderimpl.build(sessionfactorybuilderimpl.java:444) @ org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl.java:879) ... 45 more caused by: java.lang.arrayindexoutofboundsexception: 0 @ org.hibernate.persister.collection.abstractcollectionpersister.generateselectsizestring(abstractcollectionpersister.java:1017) @ org.hibernate.persister.collection.abstractcollectionpersister.<init>(abstractcollectionpersister.java:504) @ org.hibernate.persister.collection.basiccollectionpersister.<init>(basiccollectionpersister.java:57) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:423) @ org.hibernate.persister.internal.persisterfactoryimpl.createcollectionpersister(persisterfactoryimpl.java:152) ... 49 more 

for jpa , hibernate, use still relatively unfamiliar. so, can tell me, what's wrong me, please?

thanks!

ok, resolve problem track hibernate code. , because codes don't standard pojo.

it means properties of classes may don't have getter or setter. hibernate cannot find them.

but think may bug. because situation happened @ accountnumber , encryptedpassword. , belong account.

in other words, if properties belong tenant or account, hibernate can find them, if them don't have getter , setter. if properties belong accountnumber , encryptedpassword, hibernate wouldn't find them when them don't have getter , setter.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -