随笔 - 303  文章 - 883  trackbacks - 0
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

欢迎光临! 
闲聊 QQ:1074961813

随笔分类(357)

我管理的群

公共blog

  • n维空间
  • Email : java3d@126.com 群 : 12999758

参与管理的论坛

好友的blog

我的其他blog

朋友的网站

搜索

  •  

最新评论

spring整合hibernate时候往往出现sessionfatory报错问题,请注意spring整合hibernate的时候最好不要配置HibernateSessionFactory

下面的代码使用了HibernateSessionFactory 原因是保留了hinetnate.cfg.xml 我认为也是一种解决办法


改代码使用的数据库为 oracle10g

 代码比较长 贴出部分内容 其他的请自己下去看  点击下载 hibernate_spring.zip

package com.lusm.vo;

/**
 * Hello generated by MyEclipse Persistence Tools
 
*/


public class Hello implements java.io.Serializable {

    
// Fields

    
private HelloId id;

    
// Constructors

    
/** default constructor */
    
public Hello() {
    }


    
/** full constructor */
    
public Hello(HelloId id) {
        
this.id = id;
    }


    
// Property accessors

    
public HelloId getId() {
        
return this.id;
    }


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


}

package com.lusm.vo;

/**
 * HelloId generated by MyEclipse Persistence Tools
 
*/


public class HelloId implements java.io.Serializable {

    
// Fields

    
private Long id;
    
private String name;
    
private String sex;

    
// Constructors

    
/** default constructor */
    
public HelloId() {
    }


    
/** full constructor */
    
public HelloId(Long id, String name, String sex) {
        
this.id = id;
        
this.name = name;
        
this.sex = sex;
    }


    
// Property accessors

    
public Long getId() {
        
return this.id;
    }


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


    
public String getName() {
        
return this.name;
    }


    
public void setName(String name) {
        
this.name = name;
    }


    
public String getSex() {
        
return this.sex;
    }


    
public void setSex(String sex) {
        
this.sex = sex;
    }


    
public boolean equals(Object other) {
        
if ((this == other))
            
return true;
        
if ((other == null))
            
return false;
        
if (!(other instanceof HelloId))
            
return false;
        HelloId castOther 
= (HelloId) other;

        
return ((this.getId() == castOther.getId()) || (this.getId() != null
                
&& castOther.getId() != null && this.getId().equals(
                castOther.getId())))
                
&& ((this.getName() == castOther.getName()) || (this.getName() != null
                        
&& castOther.getName() != null && this.getName()
                        .equals(castOther.getName())))
                
&& ((this.getSex() == castOther.getSex()) || (this.getSex() != null
                        
&& castOther.getSex() != null && this.getSex().equals(
                        castOther.getSex())));
    }


    
public int hashCode() {
        
int result = 17;

        result 
= 37 * result + (getId() == null ? 0 : this.getId().hashCode());
        result 
= 37 * result
                
+ (getName() == null ? 0 : this.getName().hashCode());
        result 
= 37 * result
                
+ (getSex() == null ? 0 : this.getSex().hashCode());
        
return result;
    }


}

运行结果
log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.

Hibernate: select hello0_.ID as ID2_, hello0_.NAME as NAME2_, hello0_.SEX as SEX2_ from LUSM.HELLO hello0_
id    name    sex
---------------

123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男
123    lusm    男

如有错误或者疑问欢迎留言

地震让大伙知道:居安思危,才是生存之道。
posted on 2007-11-08 11:48 小寻 阅读(472) 评论(0)  编辑  收藏 所属分类: j2se/j2ee/j2me

只有注册用户登录后才能发表评论。


网站导航: