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 8600677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:40:13+00:00 2026-06-12T01:40:13+00:00

When MBean call the following getAll method, this method return empty. @Repository(bookRepository) @Transactional(propagation =

  • 0

When MBean call the following getAll method, this method return empty.

@Repository("bookRepository")
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public class BookRepositoryImpl implements BookRepository {

@Autowired
private SessionFactory sessionFactory;

@SuppressWarnings("unchecked")
public List<Book> getAll() {

    return getSession().createCriteria(Book.class).list();
}

private Session getSession() {
    return sessionFactory.getCurrentSession();
}

}

Book class:

@Entity
@Table(name = "book")
public class Book implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 2581522135048868175L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "title", unique = true, nullable = false)
    private String title;
    @Column(name = "author", nullable = false)
    private String author;
    @Column(name = "isbn_code", unique = true, nullable = false, length = 10)
    private String isbnCode;
    @Column(name = "year")
    private Integer year;
    @Column(name = "price")
    private Double price;


    // Constructors

// Getters and Setters

}

application context:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                                               xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">

<context:annotation-config /> <!-- bean definitions go here -->
<context:component-scan base-package="br.com.myproject.faces">
    <context:include-filter type="annotation"
        expression="org.springframework.stereotype.Controller" />
</context:component-scan>

<context:component-scan base-package="br.com.myproject.service.impl">
    <context:include-filter type="annotation"
        expression="org.springframework.stereotype.Service" />
</context:component-scan>

<context:component-scan base-package="br.com.myproject.domain.model">
    <context:include-filter type="annotation"
        expression="org.springframework.stereotype.Repository" />
</context:component-scan>

<!-- HIBERNATE configuration INIT -->

<context:property-placeholder location="classpath:hibernate.properties" />

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

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

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan">
        <list>
            <value>org.camelcode.model</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <!-- <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> -->
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        </props>
    </property>
</bean>

<!-- HIBERNATE configuration END -->

Ps: I insert records in book table and all instances injected are OK.

  • 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-12T01:40:16+00:00Added an answer on June 12, 2026 at 1:40 am

    Do you have this entry in your hibernate-config.xml

    <property name="packagesToScan">
                <list>
                    <value>Here you need to mention package name where your book class resides</value>
                </list>
            </property>
    

    or need to mention mapping class like below

    <mapping class="package.Book"/>
    

    Are you missing these entries?

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

Sidebar

Related Questions

So I am appending the following after an AJAX call, and this AJAX call
Please see the following statements: char a[5]=jgkl; // let's call this Statement A char
I know that one can call the following API to hibernate the system: SetSuspendState(TRUE,
I have the following API call: URL: /api/some-call Method: PUT PARAMS: No params Its
I've tried following this link Asynchronous call but some classes are obsolete. So I
I have an question about the following code (Is this call dynamic binding?). I
I have register my MBean app this way: ObjectName appName = new ObjectName(testpack.Application:name=myApp); MBeanServer
In General, we use the following code to invoke a MBean in JBOSS AS
I have an ajax call that refreshes the following table. Can I have the
I have the following code that just lists all MBean names found in platform

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.