Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:45:06+00:00 2026-06-07T08:45:06+00:00

i am using hibernate 3.5.1-Final , with spring 3.0.5.RELEASE and i am using the

  • 0

i am using hibernate 3.5.1-Final, with spring 3.0.5.RELEASE
and i am using the following configuration for OpenSessionInViewFilter:

<filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    <init-param>
      <param-name>sessionFactoryBeanName</param-name>
      <param-value>sessionFactory</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
  </filter-mapping>

suppose that i have the following entity:

@SuppressWarnings("serial")
@Entity
@Table(name = "adpage", catalog = "mydb")
public class Adpage implements java.io.Serializable {

    @Id
    @Column(name = "pkid", nullable = false, length = 50)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(fetch = FetchType.EAGER)
    private long pageId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "audio_file_id", unique = true, nullable = true)
    private AudioFile audioFile ;

}

and my backing bean is as follows:

@Component("myBean")
@Scope("view")
public class MyBean {

    @Autowired
    private AdPageDao adPageDao;

    @Autowired
    private AdPageService adPageService;

     public void preRender() {
                adPageObj = adPageDao.getAdPageByID(adPageId);
    }

    public void deleteAdPage(Adpage adPage) {
        adPageService.deleteAdPage(adPage);
    }



}

my service is as follows:

@Service
public class AdPageService {

    @Autowired
    private AudioFileDao audioFileDao;

    public void deleteAdPage(Adpage adPage) {


        if (adPage.getAudioFile() != null) {
            log.debug("deleting audio file: "
                    + adPage.getAudioFile().getName() + " for adpage: " // exception here
                    + adPage.getName());
            audioFileDao.deleteAudioFile(adPage.getAudiofileref());
            GeneralUtils.deleteFilePhysically(adPage.getAudioFile()
                    .getName();
        }

    }


}

my xhtml page is as follows:

<f:event type="preRenderView" listener="#{myBean.preRender}" />
<ice:panelGrid columns="2">

                 <ice:outputLabel id="fileName">File Name:</ice:outputLabel>
                 <ice:outputText value="#{myBean.adPageObj.audioFile.originalName}"></ice:outputText>

                 <ice:outputLabel id="fileLength">File Length:</ice:outputLabel>
                 <ice:outputText value="#{myBean.adPageObj.audioFile.length}"></ice:outputText>

                 <ice:outputLabel id="fileDesc">Description:</ice:outputLabel>
                 <ice:outputText value="#{myBean.adPageObj.audioFile.description}"></ice:outputText>

               </ice:panelGrid>

in the xhtml page the lazy loading works with no problems, and the file data is displayed correctly, but when deleting the file, i am getting the following error in the delete service method: AdPageService.deleteAdPage

Could not initialize proxy - no Session

please advise how to fix this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:45:08+00:00Added an answer on June 7, 2026 at 8:45 am

    If the AdPage object was loaded in your view (a previous Hibernate session due to the OpenSessionInViewFilter), then lazy-loading does not work because the entity is “detached” now.

    To solve the lazy-loading problem you could do:

    1. reattach the entity to the current Hibernate session
    2. do an eager fetch before to ensure all attributes are loaded
    3. reload the entity by it’s id (pageId here)

    I’d go for option 3 (reload by it’s id) to get a fresh entity (which could have changed while displaying / submitting the form).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Hibernate 3.6.8.Final and Spring 3.0.5.RELEASE , I'm trying to add some Common DAO
I'm using Spring 3.1.0.RELEASE with Hibernate 4.0.1.Final. Although my application functions when I deploy
I'm using Spring 3.1.0.RELEASE, Hibernate 4.0.1.Final, and MySQL 5.1. What is the pooled data
We are using Spring MVC 3.0.5.RELEASE with Hibernate 3.5.4-Final without transactions. Every time we
I am using Hibernate with spring. I have a model-class like this. @Entity @Table(name
I am getting the following exception: org.springframework.orm.hibernate3.HibernateSystemException: Named query not known: Entity class header:
i am using hibernate validation (4.2.0 Final) with JSF 2 and Spring and here's
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
I'm using Hibernate 3.6.7-Final and Spring 3.0.5. I have entity like this @Entity public
I'm trying to persist a very simple class using Hibernate. I'm not using Spring,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.