Create Hibernate entity

    0

    31

    Leoni Lubbinge

    Create a Hibernate entity with an auto-generated id field and a version field for concurrent modifications

    Shortcut: entity

    import javax.persistence.Entity;
    import javax.persistence.GenerationType;
    import javax.persistence.Table;
    
    @Entity
    @Table(name = &[USER_INPUT], schema = &[USER_INPUT)
    public class filename {
        @javax.persistence.Version
        @javax.persistence.Column(name = "version")
        int version;
    
        @javax.persistence.Id
        @javax.persistence.Column(name = "id")
        @javax.persistence.GeneratedValue(strategy = GenerationType.IDENTITY)
        private long id;
    
        public int getVersion() {
            return version;
        }
    
        public long getId() {
            return id;
        }
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.