Announcement Announcement Module
Collapse
No announcement yet.
Hibernate Annotated Class does not return results? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate Annotated Class does not return results?

    I have an Annotated Class that I am trying to use with hibernate to pull data, but I'm uncertain why I'm not seeing any results.

    Here is my annotated class:
    Code:
    package packagename;
    
    import java.sql.Timestamp;
    
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    
    @Entity
    @Table(name = "wlp.wlpplan01_bot_tmplt")
    public class WineLifeCycleTemplate {
    
    	private int sys_i;
    	private int site_sys_i;
    	private boolean micro_x;
    	private int yr_n;
    	private String bot_wn_typ_i;
    	private int ver_n;
    	private boolean stat_x;
    	private boolean que_stat_x;
    	private String creat_by_i;
    	private Timestamp creat_t;
    
    	public WineLifeCycleTemplate() {
    	}
    
    	@Id
    	@Column(name = "sys_i")
    	public int getSys_i() {
    		return sys_i;
    	}
    
    	public void setSys_i(int sys_i) {
    		this.sys_i = sys_i;
    	}
    
    	@Column(name = "site_sys_i")
    	public int getSite_sys_i() {
    		return site_sys_i;
    	}
    
    	public void setSite_sys_i(int site_sys_i) {
    		this.site_sys_i = site_sys_i;
    	}
    
    	@Column(name = "micro_x")
    	public boolean isMicro_x() {
    		return micro_x;
    	}
    
    	public void setMicro_x(boolean micro_x) {
    		this.micro_x = micro_x;
    	}
    
    	@Column(name = "yr_n")
    	public int getYr_n() {
    		return yr_n;
    	}
    
    	public void setYr_n(int yr_n) {
    		this.yr_n = yr_n;
    	}
    
    	@Column(name = "bot_wn_typ_i")
    	public String getBot_wn_typ_i() {
    		return bot_wn_typ_i;
    	}
    
    	public void setBot_wn_typ_i(String bot_wn_typ_i) {
    		this.bot_wn_typ_i = bot_wn_typ_i;
    	}
    
    	@Column(name = "ver_n")
    	public int getVer_n() {
    		return ver_n;
    	}
    
    	public void setVer_n(int ver_n) {
    		this.ver_n = ver_n;
    	}
    
    	@Column(name = "stat_x")
    	public boolean isStat_x() {
    		return stat_x;
    	}
    
    	public void setStat_x(boolean stat_x) {
    		this.stat_x = stat_x;
    	}
    
    	@Column(name = "que_stat_x")
    	public boolean isQue_stat_x() {
    		return que_stat_x;
    	}
    
    	public void setQue_stat_x(boolean que_stat_x) {
    		this.que_stat_x = que_stat_x;
    	}
    
    	@Column(name = "creat_by_i")
    	public String getCreat_by_i() {
    		return creat_by_i;
    	}
    
    	public void setCreat_by_i(String creat_by_i) {
    		this.creat_by_i = creat_by_i;
    	}
    
    	@Column(name = "creat_t")
    	public Timestamp getCreat_t() {
    		return creat_t;
    	}
    
    	public void setCreat_t(Timestamp creat_t) {
    		this.creat_t = creat_t;
    	}
    
    }
    Here is my DAO class...
    Code:
    package com.company.springwineplanning.repository;
    
    import java.util.List;
    
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
    
    import com.company.springwineplanning.domain.WineLifeCycleTemplate;
    
    public class WineLifeCycleTemplateDaoImpl extends HibernateDaoSupport implements WineLifeCycleTemplateDao {
    	
    	public List<WineLifeCycleTemplate> getWineLifeCycleTemplates() {
    		List<WineLifeCycleTemplate> list = getHibernateTemplate().loadAll(WineLifeCycleTemplate.class);
    		return list;
    	}	
    	
    }
    I'm pretty sure my hibernate configuration is setup properly for connecting to the database. 1) my log4J output appears to indicate successful login and 2) I can see an active session via phpmyadmin for the database.

    Does anyone have any ideas on how I might resolve this issue?
    Last edited by ewong1; Jul 31st, 2009, 03:34 PM. Reason: Added more info...

  • #2
    Hi,

    Check that in the context of Spring have defined the annotated classes in sessionFactory bean properties.

    For example:

    Code:
     <property name="annotatedClasses">
                     <list>
                        <value>packcage.JavaClassExample</value>
                     </list>
              </property>

    Comment


    • #3
      It works!

      Thanks! After reviewing your response I did have to modify the xml sessionfactory configuration:

      Code:
      <mapping class="classname" />
      Once I did that properly, the system returned results.

      Comment

      Working...
      X