Direction: Take highway 2 from Monroe heading east, exit at milepost 35 for Mt. Index Rd. Map
Album (74 photos)
Why a Book?Read more ...You may ask "Why a Maven book? There are plenty of documents online, right?". The problem of diving into any new software project is the problem of where to begin. Yes, there is a growing wealth of information pertaining to the Maven project - but it is scattered and piecemeal. They make great reference materials (we even used some docs for this book) - but many developers, myself included, desire a narrative - a jolly stroll through the growing Maven metropolis - a place to see the grand sites without being overwhelmed - where does the yellow-brick road begin? Here.
/** * Ordinary JPA sequence. * If the Long is changed into BigInteger, * there will be runtime error complaining about the type of primary key */ @Id @Column(name = "id", precision = 12) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "XyzIdGenerator") @SequenceGenerator(name = "XyzIdGenerator", sequenceName = "xyz_id_sequence") public Long getId() { return id; }
Replace the JPA @SequenceGenerator with Hibernate @GenericGenerator, where the strategy can be the class name of IdGenerator.package com.mycompany.myapp.id; import org.hibernate.id.SequenceGenerator; ... public class BigIntegerSequenceGenerator extends SequenceGenerator { @Override public Serializable generate(SessionImplementor session, Object obj) { ... } }
Customized IdGenerator is one of the features in the gap between JPA and Hibernate persistence Annotations. Similar missing features in JPA include other things like @Generated annotation in Hibernate for non-primarykey generated fields.@Id @Column(name="id", precision = 32) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "XyzIdGenerator") //@SequenceGenerator(name = "XyzIdGenerator", sequenceName = "xyz_id_sequence") @GenericGenerator(name = "XyzIdGenerator", strategy = "com.mycompany.myapp.id.BigIntegerSequenceGenerator", parameters = { @Parameter(name = "sequence", value = "xyz_id_sequence") }) public BigInteger getId() { return id; }