Starting a new project I’d like to use Hibernate annotations with MySQL instead of the configuration files I’ve used so far.
And I can’t seem to find the equivalent of:
<id name="id" type="long" >
<generator class="native"></generator>
</id>
I tried using:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "native")
private long id;
but got:
org.hibernate.AnnotationException: Unknown Id.generator: native
or:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
Give me:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: PROCEDURE projectName.identity does not exist
Does anyone successfully deployed MySQL and Hibernate3 annotations for automatically generating ids?
Prior to version 5.0, using the strategy
AUTOwas the equivalent of usingnativein a mapping. This used theLegacyFallbackInterpreter:Since Hibernate 5.0, the default interpreter is the
FallbackInterpeterwhich will either use a SEQUENCE generator or TABLE generator depending on the underlying database.To use the
LegacyFallbackInterpreter, sethibernate.id.new_generator_mappingstofalse.