See the stack overflow issue: http://stackoverflow.com/questions/3194721/bypass-generatedvalue-in-hibernate-merge-data-not-in-db which is a method for bypassing the @GeneratedValue when you set it explicitly on an entity before persisting it. There is no other method I've found to be able to achieve the same results. While this method works great for a functioning system, it unfortunately breaks the HBM2DDL and JPA 2.1 schema generation by excluding the script to set the column to auto generate. The defect is in the org.hibernate.mapping.SimpleValue class in the "isIdentityColumn" method which is: public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect) { identifierGeneratorFactory.setDialect( dialect ); return identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy ).equals(IdentityGenerator.class); } If we simply change the function to be slightly less restrictive and include subclasses of IdentityGenerator, we get: public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect) { identifierGeneratorFactory.setDialect( dialect ); return IdentityGenerator.class.isAssignableFrom(identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy )); } |