日期:2014-05-18  浏览次数:20694 次

重用hibernate问题
class a {
  id
  name
  String getIdn(){
  return("1-"+getName())
  }
get 
set
....


对应hibernate a.hbm.xml 

查询数据库得到getIdn()
结果:
"1-张三"
"1-李四"

比如这个a在这个模块显示的就是 "1-张三" 这种形式的,在其他模块我要显示 "张三" 或"2-张三"的

现在用的是a.java---a.hbm.xml ,其他模块在重复一次b.java--b.hbm.xml,其中就getIdn()不一样。


有什么其他方法:???
我想在其他模块这样。。。
class b entends a{

  String getIdn(){
  return getname();
  }
}

我想通过 a.class 查询数据库得到class b 的getIdn() 父类又强制转换不成子类。。 


高手提供好方法。。。

------解决方案--------------------
class a { 
id 
name 
String getIdn(){ 
return("1-"+getName()) 

get
set 
 ... getIdnAnotherBype(){
return getName();
}.... 
}


在 a 中多提供几中取值的形式就可以了。
------解决方案--------------------
楼上的方法不错