hibernate 重复导入问题处理

为了开发方便 ,有时候对一些代码的移植很重要,这样可以缩短开发的时间。但是有时候也会遇到不起不期而遇的事情。hibernate映射的表名、类名一样,只是类所对应的包名不一样的情况下,程序很难知道它导入的是哪个包的类,这就需要在配置文件中在包名导入的时候写上这么一句代码<hibernate-mapping package="com.tct.db.hbm.programs" auto-import="false">

避免自动导入,然后在程序编写中 使用该类名时,利用包来指定所对应的类就可以了。

LifeLuckyResult.hbm.xml(表的映射文件)

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.tct.db.hbm.programs" auto-import="false">
  <class name="LifeLuckyResult" table="pro_LUCKY_RESULT">
    <id name="dnId" column="dn_Id" type="long">
      <generator class="sequence">
        <param name="sequence">SEQ_TEMP_LUCKY_RESULT_ID</param>
      </generator>
    </id>
    <property name="dcName" column="DC_NAME" type="string" not-null="true" />
    <property name="dnLuckycount" column="DN_LUCKYCOUNT" type="long" not-null="true" />
    <property name="dnCreatetime" column="DN_CREATETIME" type="timestamp" not-null="true"/>
    <property name="dnAllcount" column="DN_ALLCOUNT" type="long" not-null="true"/>
    <property name="dnLuckytime" column="DN_LUCKYTIME" type="timestamp" not-null="true"/>
     <property name="dntype" column="DN_DNTYPE" type="int" not-null="true"/>
  </class>
</hibernate-mapping>

在程序代码编写的过程中编写的hql语句:

例如:

select count(*) from com.tct.db.hbm.programs.LifeLuckyResult

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值