我尝试通过WebService从我的数据库中获取数据列表。我用spring和冬眠我读过这样或这样的主题
所以我试着把一些事务放在类的顶部,在我的方法上,等等,但是不起作用,或者我没有用正确的参数把正确的东西放在正确的地方。
谢谢,如果语法不好,请原谅
编辑:我想问题是来自我的类Personne在懒惰模式下得到了与许多其他实体的链接,这是否意味着在web服务上说,当我返回对象时,我不关心这个链接?或者说全部取走
这是我的服务,接口只有@WebService注释
@WebService(endpointInterface = "eu.enslyon.stella.service.CasMessageService") @Service("CasMessageService") @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED) public class CasMessageServiceImpl implements CasMessageService { private transient Logger logger = LoggerFactory.getLogger(getClass()); @Autowired @Qualifier("CasMessageDao") protected CasMessageDao casMessageDao; @Autowired @Qualifier("IndividuUlrService") protected IndividuUlrService individuUlrService; @Override @Transactional(readOnly = true) public List get(String pLogin) { BigDecimal persId = individuUlrService.getPersIdFromLogin(pLogin); return casMessageDao.get(persId); } }
我的DAO,接口没有任何注释:
@Repository("CasMessageDao") @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED) public class CasMessageDaoImpl extends AbstractJpaDao implements CasMessageDao, java.io.Serializable { /** */ private final static List> dataTypes = new ArrayList>( Arrays.asList(new Class[] { IndividuUlr.class })); /** */ private static transient Logger logger = LoggerFactory.getLogger(CasMessageDaoImpl.class); /** */ @PersistenceContext(unitName = "grhum") private EntityManager entityManager; /** */ public CasMessageDaoImpl() { super(); } /** * * @return List> */ public List> getDataTypes() { return dataTypes; } /** * * @return EntityManager */ public EntityManager getEntityManager() { return entityManager; } @Override public List get(BigDecimal persId) { CriteriaBuilder cBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery criteriaQuery = cBuilder.createQuery(CasMessage.class); Root lRoot = criteriaQuery.from(CasMessage.class); Join lJoinTypeMessage = lRoot.join("typeCasMessage", JoinType.LEFT); Join lJoinPersonne = lRoot.join("detailPersonne", JoinType.LEFT).join("personne", JoinType.LEFT); lRoot.fetch("typeCasMessage"); lRoot.fetch("detailPersonne").fetch("personne"); criteriaQuery.where(cBuilder.and(cBuilder.isNull(lRoot. get("dEnd")), cBuilder.lessThanOrEqualTo(lRoot. get("countignore"), lJoinTypeMessage. get("nbAffichage")), cBuilder.equal(lJoinPersonne. get("persId"), persId))); Query query = entityManager.createQuery(criteriaQuery); List lRes = query.getResultList(); return lRes; } }
我的实体:
@Entity @Table(name = "CAS_MESSAGE", schema = "STELLA") public class CasMessage implements java.io.Serializable { private int idCasMessage; private TypeCasMessage typeCasMessage; private Date dStart; private Date dUpdate; private Date dEnd; private int countignore; private DetailPersonne detailPersonne; @Override public String toString() { return "CasMessage [idCasMessage=" + idCasMessage + ", dStart=" + dStart + ", dUpdate=" + dUpdate + ", dEnd=" + dEnd + ", countignore=" + countignore + ", detailPersonne=" + detailPersonne + "]"; } public CasMessage() { } @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CAS_MESSAGE_SEQ") @SequenceGenerator(sequenceName = "STELLA.CAS_MESSAGE_SEQ", name = "CAS_MESSAGE_SEQ", allocationSize = 1) @Column(name = "ID_CAS_MESSAGE", unique = true, nullable = false, precision = 8, scale = 0) public int getIdCasMessage() { return idCasMessage; } public void setIdCasMessage(int idCasMessage) { this.idCasMessage = idCasMessage; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ID_TYPE_CAS_MESSAGE") public TypeCasMessage getTypeCasMessage() { return typeCasMessage; } public void setTypeCasMessage(TypeCasMessage typeCasMessage) { this.typeCasMessage = typeCasMessage; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "D_START", length = 7) public Date getdStart() { return dStart; } public void setdStart(Date dStart) { this.dStart = dStart; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "D_UPDATE", length = 7) public Date getdUpdate() { return dUpdate; } public void setdUpdate(Date dUpdate) { this.dUpdate = dUpdate; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "D_END", length = 7) public Date getdEnd() { return dEnd; } public void setdEnd(Date dEnd) { this.dEnd = dEnd; } @Column(name = "COUNTIGNORE", unique = true, nullable = false, precision = 8, scale = 0) public int getCountignore() { return countignore; } public void setCountignore(int countignore) { this.countignore = countignore; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "PERS_ID") public DetailPersonne getDetailPersonne() { return this.detailPersonne; } public void setDetailPersonne(DetailPersonne detailPersonne) { this.detailPersonne = detailPersonne; } }
@Entity @Table(name = "TYPE_CAS_MESSAGE", schema = "STELLA") public class TypeCasMessage implements java.io.Serializable { private int idTypeCasMessage; private String message; private String url; private int nbJour; private int nbAffichage; public TypeCasMessage() { } @Override public String toString() { return "TypeCasMessage [idTypeCasMessage=" + idTypeCasMessage + ", message=" + message + ", url=" + url + ", nbJour=" + nbJour + ", nbAffichage=" + nbAffichage + "]"; } @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TYPE_CAS_MESSAGE_SEQ") @SequenceGenerator(sequenceName = "STELLA.TYPE_CAS_MESSAGE_SEQ", name = "TYPE_CAS_MESSAGE_SEQ", allocationSize = 1) @Column(name = "ID_TYPE_CAS_MESSAGE", unique = true, nullable = false, precision = 8, scale = 0) public int getIdTypeCasMessage() { return idTypeCasMessage; } public void setIdTypeCasMessage(int idTypeCasMessage) { this.idTypeCasMessage = idTypeCasMessage; } @Column(name = "MESSAGE") @Lob public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @Column(name = "URL", length = 500) public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } @Column(name = "NB_JOUR", unique = true, nullable = false, precision = 8, scale = 0) public int getNbJour() { return nbJour; } public void setNbJour(int nbJour) { this.nbJour = nbJour; } @Column(name = "NB_AFFICHAGE", unique = true, nullable = false, precision = 8, scale = 0) public int getNbAffichage() { return nbAffichage; } public void setNbAffichage(int nbAffichage) { this.nbAffichage = nbAffichage; } }
跟踪:
org.apache.cxf.interceptor.Fault: Marshalling Error: could not initialize proxy - no Session at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:249) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:111) at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:78) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:144) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:170) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:165) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:286) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:185) at eu.enslyon.stella.model.CarteCumul_$$_jvst22d_7.getDDebResto(CarteCumul_$$_jvst22d_7.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.get(Accessor.java:347) at com.sun.xml.bind.v2.runtime.reflect.Accessor.getUnadapted(Accessor.java:149) at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.hasValue(TransducedAccessor.java:247) at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:98) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65) at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168) at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:155) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:152) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:189) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:323) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:72) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95) at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:532) at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:222) ... 64 more
Conf for Entity Manager
<pre>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:config.properties" />
</bean>
<!-- Atomikos Transaction Manager -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init" destroy-method="close">
<property name="forceShutdown" value="true" />
<property name="startupTransactionService" value="true" />
<property name="transactionTimeout" value="3600" />
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" />
<!-- JTA transactions from Atomikos -->
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
<property name="transactionSynchronizationName" value="SYNCHRONIZATION_ON_ACTUAL_TRANSACTION" />
</bean>
<!-- Atomikos Data Sources -->
<bean name="grhumDS" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<property name="uniqueResourceName" value="[VALUE]" />
<property name="url" value="${grhum.connection.url}" />
<property name="user" value="${grhum.connection.username}" />
<property name="password" value="${grhum.connection.password}" />
<property name="driverClassName" value="${grhum.connection.driver_class}" />
<property name="maxPoolSize" value="150" />
<property name="borrowConnectionTimeout" value="30" />
</bean>
<bean name="protecDS" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<property name="uniqueResourceName" value="[VALUE]" />
<property name="url" value="${protec.connection.url}" />
<property name="user" value="${protec.connection.username}" />
<property name="password" value="${protec.connection.password}" />
<property name="driverClassName" value="${protec.connection.driver_class}" />
<property name="maxPoolSize" value="150" />
<property name="borrowConnectionTimeout" value="30" />
</bean>
<bean name="sesameDS" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<property name="uniqueResourceName" value="[VALUE]" />
<property name="url" value="${sesame.connection.url}" />
<property name="user" value="${sesame.connection.username}" />
<property name="password" value="${sesame.connection.password}" />
<property name="driverClassName" value="${sesame.connection.driver_class}" />
<property name="maxPoolSize" value="150" />
<property name="borrowConnectionTimeout" value="30" />
</bean>
<!-- vendor adapter -->
<bean id="grhumJPAVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${grhum.show_sql}" />
<property name="generateDdl" value="${grhum.generateDdl}" />
<property name="databasePlatform" value="${grhum.dialect}" />
</bean>
<bean id="protecJPAVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${protec.show_sql}" />
<property name="generateDdl" value="${protec.generateDdl}" />
<property name="databasePlatform" value="${protec.dialect}" />
</bean>
<bean id="sesameJPAVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${sesame.show_sql}" />
<property name="generateDdl" value="${sesame.generateDdl}" />
<property name="databasePlatform" value="${sesame.dialect}" />
</bean>
<bean id="grhum"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="grhumDS" />
<property name="persistenceUnitName" value="grhum" />
<property name="jpaVendorAdapter" ref="grhumJPAVendorAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" />
<entry key="hibernate.connection.release_mode" value="on_close" />
<entry key="hibernate.search.default.indexBase" value="${catalina.base}/tmp/indexes" />
<entry key="hibernate.transaction.jta.platform"
value="com.atomikos.icatch.jta.hibernate4.AtomikosPlatform" />
</map>
</property>
<property name="packagesToScan" value="eu.enslyon.stella.model" />
</bean>
<bean id="protec"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="protecDS" />
<property name="persistenceUnitName" value="protec" />
<property name="jpaVendorAdapter" ref="protecJPAVendorAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" />
<entry key="hibernate.connection.release_mode" value="on_close" />
<entry key="hibernate.search.default.indexBase" value="${catalina.base}/tmp/indexes" />
<entry key="hibernate.transaction.jta.platform"
value="com.atomikos.icatch.jta.hibernate4.AtomikosPlatform" />
</map>
</property>
<property name="packagesToScan" value="eu.enslyon.stella.model.protec" />
</bean>
<bean id="sesame"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="sesameDS" />
<property name="persistenceUnitName" value="sesame" />
<property name="jpaVendorAdapter" ref="sesameJPAVendorAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup" />
<entry key="hibernate.connection.release_mode" value="on_close" />
<entry key="hibernate.search.default.indexBase" value="${catalina.base}/tmp/indexes" />
<entry key="hibernate.transaction.jta.platform"
value="com.atomikos.icatch.jta.hibernate4.AtomikosPlatform" />
</map>
</property>
</bean>
</beans>
null
我也犯了同样的错误。问题是soap响应的对象链接到持久/附加的集合。并且在封送过程中会导致延迟加载异常。我们在转换器中解决了这个问题,只需创建集合的副本。例如:带有bug的旧代码:
soapResponseDto.setBookTypes(entity.getBookTypes);
新的固定代码:
soapReponseDto.setBookType(new ArrayList<>(entity.getBookTypes));
因此您需要检查soap响应DTO类是否不包含任何来自实体的类。
我通过将“@XMLTransient”放在上面来解决这个问题:
@XmlTransient @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "PERS_ID") public DetailPersonne getDetailPersonne() { return this.detailPersonne; }
参见CXF:当对象通过SOAP发送时,如何排除某些属性?
我不明白是CXF序列化了我的对象,而没有hibernate,所以我用坏术语搜索,什么也没有找到
问题内容: 我有一个看起来像这样的错误: 无法初始化代理-没有会话 我正在使用java,hibernate和spring。尝试生成PDF文档时会出现此错误,我正在按照以下步骤即时生成它并存储在数据库中。 我通过POST方法向应用发送了请求。这将即时生成PDF并显示给用户。 在该请求之后,我发送了另一个请求,但是通过ajax发送了一个请求。这将生成相同的PDF,但会将其保存在数据库中。 该错误表明由
问题内容: 我有2台物理服务器,我的Web应用程序命中该服务器由负载均衡器管理。我总是得到- org.hibernate.LazyInitializationException:无法初始化代理-没有会话 当其中一台服务器受到攻击而另一台服务器运行平稳而没有任何问题时。我有一个由应用程序启用和管理的本地托管缓存存储。仅当尝试从一个表访问一个特定的列时,才会发生此异常。不管选择哪个服务器,其余的操作都
问题内容: 我的代码检索与用户有关的所有信息: 在简单地返回一组用户的ES。 我的问题是:即使会话已经关闭,为什么对象仍然具有其值(例如名称)?是该类的实例变量。但是为什么我不能检索其值却可以检索该类的常规实例变量? 是一个。 问题答案: 有关使用惰性关联的hibernate文档清楚地将这种访问称为错误。只有在会话仍处于打开状态时,才能与延迟关联的对象进行交互。文档的该部分还提供了访问对象的延迟关
问题内容: 对数据库有以下查询: 在获取employee.address.street,employee.address.houseNumber或employee.address.city时,它将失败,但以下情况除外: 员工映射: 地址映射: 对于其他类(办公室,公司等),这是绝对正常的。如果注释,则在jsp应用程序中加载地址字段的行将正常工作。怎么了?顺便说一下,尽管有异常,它仍显示有关js
问题内容: 我试图从数据库中的对象进行简单加载,但出现错误“无法初始化代理-没有会话”,知道吗?谢谢 问题答案: 尝试添加到validate方法: 发生的事情是,因为没有注释,所以没有与该方法关联的会话,并且每个查询都将在其自己的会话中运行,该会话随后将立即关闭。 该方法始终返回一个代理,与之不同(请参阅此处,了解load与get之间的差异)。 因此,返回了代理,但是由于缺少代理,因此立即关闭了创
我试图从DB中的一个对象做一个简单的加载,但是我得到的错误是“Could not initialize proxy-no session”,有什么想法吗?谢谢