`
Jonefy
  • 浏览: 11380 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

hibernate 联合主键 注解 删除操作

 
阅读更多
实体对象:
@Entity
@Table(name = "T_DBCONNECT")
@IdClass(DBPK.class)
public class DataBaseConnect implements Serializable{


private String fassettype;

private String fdbtype;

private String fdbname;

private String fserver;
   
           /**set get method **/



}
主键对象:
public class DBPK implements Serializable{

         private String fassettype;

private String fdbtype;
    
         /**set get method **/

}



@Service
public class DataBaseConnectService {
   @Autowired
   private DataBaseConnectDao dbInfoDao;
   
   DataBaseConnect connect = null;
try{
    for(DBPK id : ids){
      connect = (DataBaseConnect)this.dbInfoDao.get(DataBaseConnect.class, id);
Map<String, String> propertyMap = new HashMap<String, String>();
this.dbInfoDao.delete(connect);
}
}catch(Exception e){
throw new YssException("删除失败:" + e.getMessage());
}
}



修改类似,增,查和原hibernate的方法没区别














分享到:
评论

相关推荐

    Hibernate注解

    * @GenericGenerator —— 注解声明了一个hibernate的主键生成策略。支持十三种策略。该注解有如下属性 * name 指定生成器名称 * strategy 指定具体生成器的类名(指定生成策略)。 * parameters 得到strategy指定的...

    Hibernate注释大全收藏

    • 将类注解为 @IdClass,并将该实体中所有主键的属性都注解为 @Id @Entity @IdClass(FootballerPk.class) public class Footballer { //part of the id key @Id public String getFirstname() { return ...

    Hibernate 中文 html 帮助文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...

    最全Hibernate 参考文档

    5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...

    hibernate 体系结构与配置 参考文档(html)

    1. Hibernate入门 1.1. 前言 1.2. 第一部分 - 第一个Hibernate应用程序 1.2.1. 第一个class 1.2.2. 映射文件 1.2.3. Hibernate配置 1.2.4. 用Ant构建 1.2.5. 启动和辅助类 1.2.6. 加载并存储对象 1.3. 第...

    Hibernate教程

    6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...

    hibernate3.04中文文档.chm

    6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...

    Hibernate3+中文参考文档

    5.4.2. 使用 JDK 5.0 的注解(Annotation) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) 6.2. 集合映射( Collection mappings ) 6.2.1. 集合外键(Collection foreign keys) 6.2.2. 集合...

    Hibernate3的帮助文档

    6.4.2. 使用 JDK 5.0 的注解(Annotation) 7. 集合类(Collections)映射 7.1. 持久化集合类(Persistent collections) 7.2. 集合映射( Collection mappings ) 7.2.1. 集合外键(Collection foreign keys) 7.2.2. ...

    hibernate 框架详解

    触发器实现的主键生成器(Primary keys assigned by triggers) 6.1.5. composite-id 6.1.6. 鉴别器(discriminator) 6.1.7. 版本(version)(可选) 6.1.8. timestamp (optional) 6.1.9. property 6.1.10. ...

    Hibernate参考文档

    5.5.2. 使用 JDK 5.0 的注解(Annotation) 5.6. 数据库生成属性(Generated Properties) 5.7. 辅助数据库对象(Auxiliary Database Objects) 6. 集合类(Collections)映射 6.1. 持久化集合类(Persistent collections) ...

    JAVA上百实例源码以及开源项目

    从内存中清除,从账户中取出amt,如果amt&gt;账户余额抛出异常,一个实体Bean可以表示不同的数据实例,我们应该通过主键来判断删除哪个数据实例…… ejbCreate函数用于初始化一个EJB实例 5个目标文件,演示Address ...

    JAVA上百实例源码以及开源项目源代码

    保证Bean正常被激活和钝化,EJB对象是用完毕,从内存中清除,从账户中取出amt,如果amt&gt;账户余额抛出异常,一个实体Bean可以表示不同的数据实例,我们应该通过主键来判断删除哪个数据实例…… ejbCreate函数用于初始...

    springmybatis

    MyBatis使用简单的XML或注解用于配置和原始映射,将接口和Java的POJOs(Plan Old Java Objects,普通的Java对象)映射成数据库中的记录. orm工具的基本思想 无论是用过的hibernate,mybatis,你都可以法相他们有一个...

Global site tag (gtag.js) - Google Analytics