Announcement Announcement Module
Collapse
No announcement yet.
error:id to load is required for loading Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error:id to load is required for loading

    Hi,

    I am getting following error:-

    INFO: In UserSession.getAccount::::
    Jan 23, 2006 11:06:23 AM org.springframework.samples.jpetstore.domain.Accou nt getUsername
    INFO: In Account.getUsername::::
    Jan 23, 2006 11:06:23 AM org.springframework.samples.jpetstore.domain.logic .PetStoreImpl getAccount
    INFO: In PetStoreImpl.getAccount::::
    Jan 23, 2006 11:06:23 AM org.springframework.samples.jpetstore.dao.hibernat e.HibernateImplAccountDao getAccount
    INFO: In HibernateImplAccountDao.getAccount:::::::::::::
    Jan 23, 2006 11:06:23 AM org.springframework.web.servlet.FrameworkServlet serviceWrapper
    SEVERE: Could not complete request
    java.lang.IllegalArgumentException: id to load is required for loading
    at org.hibernate.event.LoadEvent.<init>(LoadEvent.jav a:51)
    at org.hibernate.event.LoadEvent.<init>(LoadEvent.jav a:33)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.ja va:600)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.ja va:596)
    at org.springframework.orm.hibernate3.HibernateTempla te$3.doInHibernate(HibernateTemplate.java:425)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:312)
    at org.springframework.orm.hibernate3.HibernateTempla te.load(HibernateTemplate.java:419)
    at org.springframework.orm.hibernate3.HibernateTempla te.load(HibernateTemplate.java:414)
    at org.springframework.samples.jpetstore.dao.hibernat e.HibernateImplAccountDao.getAccount(HibernateImpl AccountDao.java:26)
    at org.springframework.samples.jpetstore.domain.logic .PetStoreImpl.getAccount(PetStoreImpl.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)

    The method called is
    public Account getAccount(String username) throws DataAccessException {
    Account account=(Account)getHibernateTemplate().load(Accou nt.class,username);
    return (Account) getHibernateTemplate().load(Account.class,username );

    So the error is coming while setting the id in the bean Account.java
    We already have userId mapped in the hbm.xml like this in the Account.class

    <id name="id" type="string" unsaved-value="null" >
    <column name="userid" sql-type="char(32)" not-null="true"/>
    <generator class="assigned"/>
    </id>


    Can anybody help me out?
    What could be the cause of the error?

    Regards,
    Avinash

  • #2
    error: id to load is required for loading

    The method called is

    public Account getAccount(String username) throws DataAccessException {
    Account account=(Account)getHibernateTemplate().load(Accou nt.class,username);
    // error is coming here
    return (Account) getHibernateTemplate().load(Account.class,username );

    Regards,
    Avinash

    Comment


    • #3
      Hmm, is the username null?

      Can you debug the value of username.

      Comment


      • #4
        Re:error

        Thanks.

        I was able to solve the problem by correcting the entry of the property in the hbm.xml

        the rectification was
        <id name="username" type="string" unsaved-value="null" >
        <column name="userid" sql-type="char(32)" not-null="true"/>
        <generator class="assigned"/>
        </id>

        while initially it was
        <id name="id" type="string" unsaved-value="null" >
        <column name="userid" sql-type="char(32)" not-null="true"/>
        <generator class="assigned"/>
        </id>

        Now things are working fine.

        Regards,
        Avinash

        Comment

        Working...
        X