美文网首页
Springboot JPA+Oracle遇到的问题

Springboot JPA+Oracle遇到的问题

作者: phoebe_gyq | 来源:发表于2017-11-24 13:24 被阅读0次

    1.通过查询条件查到数据内容后改变其中一项 再保存可以保存,然而通过直接插入一条数据 就无法找到结果集

    解决: 由于mysql可以自增长,oracle不可以,需要添加hibernate_sequence
    补充知识:SpringJPA 默认用hibernate

    解决步骤一:MyCity 实体类中添加
    public class MyCity {
        @Id @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "my_entity_seq_gen")
        @SequenceGenerator(name="my_entity_seq_gen",sequenceName = "S_MYCITY")
        private Long id;
    
    解决步骤二:oracle数据库中添加脚本
    create sequence S_MYCITY
    minvalue 1
    maxvalue 999999999999999999999999999
    start with 1
    increment by 1
    nocache;
    

    相关文章

      网友评论

          本文标题:Springboot JPA+Oracle遇到的问题

          本文链接:https://www.haomeiwen.com/subject/zyexbxtx.html