简体   繁体   English

Spring DATA JPA + Hibernate-无法初始化代理-修复后无会话:

[英]Spring DATA JPA + Hibernate - could not initialize proxy - no Session after fix:

Good day, all. 大家好 I'm newbie in Spring Data + JPA. 我是Spring Data + JPA的新手。 And i need your help. 我需要你的帮助。 It's my first question on stackoverflow, that sorry if i formed my Question not correct. 这是我关于stackoverflow的第一个问题,对不起,如果我提出的问题不正确。

I start to realise project using Spring Data + JPA + Hibernate, Spring MVC, Use MySQL. 我开始使用Spring Data + JPA + Hibernate,Spring MVC和Use MySQL实现项目。

I have DB scheme: 我有数据库方案:

DB of project 项目数据库

DB scheme 数据库方案

application context: 应用程序上下文:

<context:property-placeholder location="classpath:util.properties" />
<!--Activates various annotations to be detected in bean classes: Spring's @Required and @Autowired and so on-->
<context:annotation-config/>

<!-- Datasource.  -  MySQL -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClass}"/>
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}" />
</bean>

<!--Do not forget activate @Transactional JPA annotation with <annotation-driven/>-->
<!-- JPA Persistence Context and EntityManager configuration -->
<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
    <!--packagesToScan - search Entity and mapping them -->
    <property name="packagesToScan" value="by.GetItFree" />
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" >
            <property name="generateDdl" value="true" />
            <property name="showSql" value="true" />
        </bean>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">false</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.enable_lazy_load_no_trans">true</prop>
        </props>
    </property>
</bean>

<!-- Automatic Transaction Participation-->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<jpa:repositories base-package="by.GetItFree.orm.repository" entity-manager-factory-ref="entityManagerFactory"
                  transaction-manager-ref="transactionManager"/>

MVC Config: MVC配置:

<!--
    mvc:annotation-driven configures Spring MVC annotations
    Support for validating @Controller inputs with @Valid, if a JSR-303 Provider is present on the classpath.
    HttpMessageConverter support for @RequestBody method parameters and @ResponseBody method return values
    from @RequestMapping or @ExceptionHandler methods.
 -->
<mvc:annotation-driven/>

<!-- activate @Transactional JPA annotation -->
<tx:annotation-driven/>

<!-- ViewResolver bean config for mapping strings to jsp views -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' -->
    <property name="order" value="1" />
    <property name="prefix" value="/WEB-INF/view" />
    <property name="suffix" value=".jsp" />
</bean>


<mvc:view-controller path="/about.html" view-name="/about/about"/>
<mvc:view-controller path="/index.html" view-name="/index"/>


<!-- Static Resources Configuration (get access to static sources such as CSS and JavaScript files) -->
<mvc:resources mapping="/resources/**" location="/resources/" />


Some of JPA Persistence Entites: 一些JPA持久性实体:

Advert: 广告:

@Entity
public class Advert {
    private int id;
    private String karmaReq;
    private byte[] image;
    private int profileId;
    private String profileUsersUsername;
    private String head;
    private String content;
    private byte ordered;
    private Timestamp date;
    private Profile profile;
    private Collection<Comment> commentsById;

    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

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

@Basic
@Column(name = "karmaReq", nullable = true, length = 45)
public String getKarmaReq() {
    return karmaReq;
}

public void setKarmaReq(String karmaReq) {
    this.karmaReq = karmaReq;
}

@Basic
@Column(name = "image", nullable = false)
public byte[] getImage() {
    return image;
}

public void setImage(byte[] image) {
    this.image = image;
}

@Basic
@Column(name = "profile_id", nullable = false)
public int getProfileId() {
    return profileId;
}

public void setProfileId(int profileId) {
    this.profileId = profileId;
}

@Basic
@Column(name = "profile_users_username", nullable = false, length = 45)
public String getProfileUsersUsername() {
    return profileUsersUsername;
}

public void setProfileUsersUsername(String profileUsersUsername) {
    this.profileUsersUsername = profileUsersUsername;
}

@Basic
@Column(name = "head", nullable = true, length = 45)
public String getHead() {
    return head;
}

public void setHead(String head) {
    this.head = head;
}

@Basic
@Column(name = "content", nullable = true, length = 450)
public String getContent() {
    return content;
}

public void setContent(String content) {
    this.content = content;
}

@Basic
@Column(name = "ordered", nullable = false)
public byte getOrdered() {
    return ordered;
}

public void setOrdered(byte ordered) {
    this.ordered = ordered;
}

@Basic
@Column(name = "date", nullable = false)
public Timestamp getDate() {
    return date;
}

public void setDate(Timestamp date) {
    this.date = date;
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Advert advert = (Advert) o;

    if (id != advert.id) return false;
    if (profileId != advert.profileId) return false;
    if (ordered != advert.ordered) return false;
    if (karmaReq != null ? !karmaReq.equals(advert.karmaReq) : advert.karmaReq != null) return false;
    if (!Arrays.equals(image, advert.image)) return false;
    if (profileUsersUsername != null ? !profileUsersUsername.equals(advert.profileUsersUsername) : advert.profileUsersUsername != null)
        return false;
    if (head != null ? !head.equals(advert.head) : advert.head != null) return false;
    if (content != null ? !content.equals(advert.content) : advert.content != null) return false;
    if (date != null ? !date.equals(advert.date) : advert.date != null) return false;

    return true;
}

@Override
public int hashCode() {
    int result = id;
    result = 31 * result + (karmaReq != null ? karmaReq.hashCode() : 0);
    result = 31 * result + Arrays.hashCode(image);
    result = 31 * result + profileId;
    result = 31 * result + (profileUsersUsername != null ? profileUsersUsername.hashCode() : 0);
    result = 31 * result + (head != null ? head.hashCode() : 0);
    result = 31 * result + (content != null ? content.hashCode() : 0);
    result = 31 * result + (int) ordered;
    result = 31 * result + (date != null ? date.hashCode() : 0);
    return result;
}

@ManyToOne
@JoinColumns({@JoinColumn(name = "profile_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "profile_users_username", referencedColumnName = "users_username", nullable = false, insertable = false, updatable = false)})
public Profile getProfile() {
    return profile;
}

public void setProfile(Profile profile) {
    this.profile = profile;
}

@OneToMany(mappedBy = "advertByAdvertId")
public Collection<Comment> getCommentsById() {
    return commentsById;
}

public void setCommentsById(Collection<Comment> commentsById) {
    this.commentsById = commentsById;
}

@Override
public String toString() {
    return "Advert{" +
            "id=" + id +
            ", karmaReq='" + karmaReq + '\'' +
            ", image=" + Arrays.toString(image) +
            ", profileId=" + profileId +
            ", profileUsersUsername='" + profileUsersUsername + '\'' +
            ", head='" + head + '\'' +
            ", content='" + content + '\'' +
            ", ordered=" + ordered +
            ", date=" + date +
            ", profile=" + profile +
            ", commentsById=" + commentsById +
            '}';
}

} }

// I know , that if i comment call profile in to String(), all will be work. //我知道,如果我在String()中注释调用概要文件,那么一切都会正常进行。

Profile 轮廓

@Entity
@IdClass(ProfilePK.class)
public class Profile {
    private int id;
    private String usersUsername;
    private Integer karma;
    private String phone;
    private byte[] icon;
    private Collection<Advert> adverts;
    private Collection<Comment> comments;
    private Collection<Message> messages;
    private Users usersByUsersUsername;
@Id
@Column(name = "id", nullable = false)
public int getId() {
    return id;
}

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

@Id
@Column(name = "users_username", nullable = false, length = 45)
public String getUsersUsername() {
    return usersUsername;
}

public void setUsersUsername(String usersUsername) {
    this.usersUsername = usersUsername;
}

@Basic
@Column(name = "karma", nullable = true)
public Integer getKarma() {
    return karma;
}

public void setKarma(Integer karma) {
    this.karma = karma;
}

@Basic
@Column(name = "phone", nullable = true, length = 15)
public String getPhone() {
    return phone;
}

public void setPhone(String phone) {
    this.phone = phone;
}

@Basic
@Column(name = "icon", nullable = true)
public byte[] getIcon() {
    return icon;
}

public void setIcon(byte[] icon) {
    this.icon = icon;
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Profile profile = (Profile) o;

    if (id != profile.id) return false;
    if (usersUsername != null ? !usersUsername.equals(profile.usersUsername) : profile.usersUsername != null)
        return false;
    if (karma != null ? !karma.equals(profile.karma) : profile.karma != null) return false;
    if (phone != null ? !phone.equals(profile.phone) : profile.phone != null) return false;
    if (!Arrays.equals(icon, profile.icon)) return false;

    return true;
}

@Override
public int hashCode() {
    int result = id;
    result = 31 * result + (usersUsername != null ? usersUsername.hashCode() : 0);
    result = 31 * result + (karma != null ? karma.hashCode() : 0);
    result = 31 * result + (phone != null ? phone.hashCode() : 0);
    result = 31 * result + Arrays.hashCode(icon);
    return result;
}

@OneToMany(mappedBy = "profile")
public Collection<Advert> getAdverts() {
    return adverts;
}

public void setAdverts(Collection<Advert> adverts) {
    this.adverts = adverts;
}

@OneToMany(mappedBy = "profile")
public Collection<Comment> getComments() {
    return comments;
}

public void setComments(Collection<Comment> comments) {
    this.comments = comments;
}

@OneToMany(mappedBy = "profile")
public Collection<Message> getMessages() {
    return messages;
}

public void setMessages(Collection<Message> messages) {
    this.messages = messages;
}

@ManyToOne
@JoinColumn(name = "users_username", referencedColumnName = "username", nullable = false, insertable = false, updatable = false)
public Users getUsersByUsersUsername() {
    return usersByUsersUsername;
}

public void setUsersByUsersUsername(Users usersByUsersUsername) {
    this.usersByUsersUsername = usersByUsersUsername;
}

@Override
public String toString() {
    return "Profile{" +
            "id=" + id +
            ", usersUsername='" + usersUsername + '\'' +
            ", karma=" + karma +
            ", phone='" + phone + '\'' +
            ", icon=" + Arrays.toString(icon) +
            ", adverts=" + adverts +
            ", comments=" + comments +
            ", messages=" + messages +
            ", usersByUsersUsername=" + usersByUsersUsername +
            '}';
}

} }

ORM ORM

AdvertDAO 广告

   /**
 * DAO interface responsible for operation with Advertising.
 * <p>
 * Created by Novik Igor on 09.02.2017.
 */
public interface AdvertDAO {

    /**
     * Method returned list of Advert's from the DB.
     *
     * @return list of Advertising's.
     */
    List<Advert> findAll();

    /**
     * Method returned list of Advert from the DB according ID.
     *
     * @param head id of the Advert;
     * @return Advertising according id.
     */
    Advert findByHead(String head);
}

AdvertDAORepository AdvertDAOR存储库

/**
 * SpringData AdvertDAO repository.
 *
 * Created by Novik Igor on 10.02.2017.
 */
public interface AdvertDAORepository extends CrudRepository<Advert,Integer> {

    List<Advert> findByHead(String head);

}

Service for Spring Data/JPA - AdvertDAOImpl Spring Data / JPA服务-AdvertDAOImpl

/**
 * Repository bean that implements JPA DAO Advert interfaces responsible for operation with Advertising from DB.
 * <p>
 * Created by nolik on 10.02.17.
 */

@Service("jpaAdvertDAO")
@Repository
@Transactional
public class AdvertDAOImpl implements AdvertDAO {

    @Autowired
    private AdvertDAORepository advertDAORepository;

    @Override
    public List<Advert> findAll() {

        return Lists.newArrayList(advertDAORepository.findAll());
    }

    @Override
    public Advert findByHead(String head) {

        return (Advert) advertDAORepository.findByHead(head);
    }
}

Test MVC Controller: 测试MVC控制器:

    @Controller
public class TestController {

    @Autowired
    AdvertDAO jpaAdvertDAO;
    @Autowired
    CommentDAO jpaCommentDAO;

    @RequestMapping(value = "/testCall", method = RequestMethod.GET)
    public ModelAndView readCookieExample() {

        System.out.println(" Test console");
        return new ModelAndView("/error/errorpage");

    }

    @RequestMapping(value = "/jpaFindAllAdvert", method = RequestMethod.GET)
    public ModelAndView jpaFindAllAdvert() {
        System.out.println("ORMController ormFindAllUsers is called");
        List<Advert> adverts = jpaAdvertDAO.findAll();
        return new ModelAndView("/error/test", "resultObject", adverts);

    }

    @RequestMapping(value = "/jpaFindAllComments", method = RequestMethod.GET)
    public ModelAndView jpaFindAllComments() {
        System.out.println("ORMController FindAllComments is called");
        List<Comment> comments = jpaCommentDAO.findAll();
        return new ModelAndView("/error/test", "resultObject", comments);

    }
}

Simple JSP for showing result of calling "/jpaFindAllAdvert" 简单的JSP,用于显示调用“ / jpaFindAllAdvert”的结果

 <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Test</title> </head> <body> <%--<a href="${adverts}" class="list-group-item">Find All Adverts</a>--%> ${resultObject} </body> </html> 

Firstly i faced with the next exception: 首先,我面临下一个例外:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: by.GetItFree.entities.Profile.adverts, could not initialize proxy - no Session
org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:563)
org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:205)
org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:542)
org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:133)
org.hibernate.collection.internal.PersistentBag.toString(PersistentBag.java:509)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Profile.toString(Profile.java:144)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Advert.toString(Advert.java:174)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
java.util.AbstractCollection.toString(AbstractCollection.java:462)
org.apache.el.lang.ELSupport.coerceToString(ELSupport.java:497)
org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:529)
org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:47)
javax.el.ELContext.convertToType(ELContext.java:304)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944)
org.apache.jsp.WEB_002dINF.view.error.test_jsp._jspService(test_jsp.java:118)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1271)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

I google that it's a result of N+1 SQL problem for Hibernate for Leazy initialisation of Joined with @ManyToONe relations. 我在Google上搜索到,这是Hibernate对带有@ManyToONe关系的Join进行Leazy初始化的N + 1 SQL问题的结果。

I use way to fix with adding: <prop key="hibernate.enable_lazy_load_no_trans">true</prop> to "Jpa Properties" 我使用添加以下内容的方法进行修复:在“ Jpa属性”中添加<prop key="hibernate.enable_lazy_load_no_trans">true</prop>

After this i faced with: StackOverflow exeption: 在此之后,我面临:StackOverflow exeption:

java.lang.StackOverflowError
java.util.AbstractCollection.toString(AbstractCollection.java:454)
org.hibernate.collection.internal.PersistentBag.toString(PersistentBag.java:510)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Profile.toString(Profile.java:144)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Advert.toString(Advert.java:174)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
java.util.AbstractCollection.toString(AbstractCollection.java:462)
org.hibernate.collection.internal.PersistentBag.toString(PersistentBag.java:510)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Profile.toString(Profile.java:144)
java.lang.String.valueOf(String.java:2994)
java.lang.StringBuilder.append(StringBuilder.java:131)
by.GetItFree.entities.Advert.toString(Advert.java:174)

Etc.. - very long listing 等等-非常长的清单

In Tocat Log in the last case - i see big listing JPQL/or HSQL i'm not shure: 在Tocat中,在最后一种情况下登录-我看到很大的列表JPQL /或HSQL,但我不知道:

  RMController ormFindAllUsers is called
Hibernate: select advert0_.id as id1_1_, advert0_.content as content2_1_, advert0_.date as date3_1_, advert0_.head as head4_1_, advert0_.image as image5_1_, advert0_.karmaReq as karmaReq6_1_, advert0_.ordered as ordered7_1_, advert0_.profile_users_username as profile_9_1_, advert0_.profile_id as profile_8_1_ from Advert advert0_
Hibernate: select profile0_.users_username as users_us1_5_0_, profile0_.id as id2_5_0_, profile0_.icon as icon3_5_0_, profile0_.karma as karma4_5_0_, profile0_.phone as phone5_5_0_, users1_.username as username1_6_1_, users1_.enabled as enabled2_6_1_, users1_.password as password3_6_1_ from Profile profile0_ inner join Users users1_ on profile0_.users_username=users1_.username where profile0_.users_username=? and profile0_.id=?
Hibernate: select adverts0_.profile_users_username as profile_9_1_0_, adverts0_.profile_id as profile_8_1_0_, adverts0_.id as id1_1_0_, adverts0_.id as id1_1_1_, adverts0_.content as content2_1_1_, adverts0_.date as date3_1_1_, adverts0_.head as head4_1_1_, adverts0_.image as image5_1_1_, adverts0_.karmaReq as karmaReq6_1_1_, adverts0_.ordered as ordered7_1_1_, adverts0_.profile_users_username as profile_9_1_1_, adverts0_.profile_id as profile_8_1_1_ from Advert adverts0_ where adverts0_.profile_users_username=? and adverts0_.profile_id=?
Hibernate: select profile0_.users_username as users_us1_5_0_, profile0_.id as id2_5_0_, profile0_.icon as icon3_5_0_, profile0_.karma as karma4_5_0_, profile0_.phone as phone5_5_0_, users1_.username as username1_6_1_, users1_.enabled as enabled2_6_1_, users1_.password as password3_6_1_ from Profile profile0_ inner join Users users1_ on profile0_.users_username=users1_.username where profile0_.users_username=? and profile0_.id=?

My progect on github: ProgectSourceCode 我在github上的progectProgectSourceCode

What's the reason of this behaiviour. 这种行为的原因是什么。 And what's the solution? 那有什么解决方案? Thx for your attention and support. 感谢您的关注和支持。

The reason you're having this problem is because associations that your view requires should be initialized inside a transaction boundary to avoid the LazyInitializationException . 您遇到此问题的原因是,应在事务边界内初始化视图所需的关联,以避免LazyInitializationException Adding an option to load collections outside of a transaction is merely a bandaid and doesn't truly address the underlying design flaw of your code. 添加选项以在事务外部加载集合只是一个临时任务,并不能真正解决代码的潜在设计缺陷。

If your view requires that you load Profile and its associated collection of Advert entities, then your either your data access should should specifically toggle that behavior or the query specify that you need that collection initialized. 如果您的视图要求您加载Profile及其与之关联的Advert实体集合,则您的数据访问权限应专门切换该行为,或者查询指定您需要初始化该集合。

There are a number of ways you can trigger this collection to be loaded as part of a query. 您可以通过多种方式触发此集合作为查询的一部分进行加载。

  • JPQL/HQL using a JOIN FETCH on the adverts collection. JPQL / HQL在adverts集合上使用JOIN FETCH
  • Specify a join fetch using the Criteria API 使用Criteria API指定联接提取
  • Use @FetchProfile to toggle a specific fetch strategy by name. 使用@FetchProfile按名称切换特定的提取策略。
  • Use @NamedEntityGraph . 使用@NamedEntityGraph

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring JPA - org.hibernate.LazyInitializationException:无法初始化代理 - 无 Z71AB3B3AE294B3ABDE46 - Spring JPA - org.hibernate.LazyInitializationException: could not initialize proxy - no Session Spring Data JPA - “无法初始化代理 - 无会话” - 方法标记为事务性 - Spring Data JPA - "could not initialize proxy - no Session" - With Methods marked as transactional Spring Data JPA,Hibernate,@ ManyToOne(fetch = FetchType.LAZY)和org.hibernate.LazyInitializationException:无法初始化代理-没有会话 - Spring Data JPA, Hibernate, @ManyToOne(fetch=FetchType.LAZY) and org.hibernate.LazyInitializationException: could not initialize proxy - no Session Hibernate / Spring3:无法初始化代理 - 没有Session - Hibernate/Spring3: could not initialize proxy - no Session JPA存储库org.hibernate.LazyInitializationException:无法初始化代理-没有会话 - JPA repository org.hibernate.LazyInitializationException: could not initialize proxy - no Session Hibernate 4 + Spring Data CrudRepository,CLI应用程序:无法延迟初始化集合:无法初始化代理-没有会话 - Hibernate 4 + Spring Data CrudRepository, CLI application: failed to lazily initialize a collection: could not initialize proxy - no Session 如何修复 org.hibernate.LazyInitializationException - 无法初始化代理 - 没有 Session - How to fix org.hibernate.LazyInitializationException - could not initialize proxy - no Session Hibernate无法初始化代理 - 没有Session - Hibernate could not initialize proxy - no Session spring boot + jpa + jersey无法初始化代理-没有会话 - spring boot + jpa + jersey could not initialize proxy - no Session 无法初始化代理-没有会话(春季休眠一对一) - could not initialize proxy - no Session (Spring-Hibernate-one to one)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM