The stack is the following: Spring MVC with Hibernate 4.2.1
Saving entities in Oracle database works correctly: after save() I get the new identifier given by the DB sequence; when I switch to MS Sql Server instance, the save() returns always 0.
Here is the ID field definition:
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq")
@SequenceGenerator(name="seq", sequenceName="SEQ_PEZZI")
@Basic(optional = false)
@Column(name = "id")
private Long id;
In debug mode, I’ve noticed that the problem is in the following line of code (in AbstractSaveEventListener.java, line 117 saveWithGeneratedId() method):
Serializable generatedId = persister.getIdentifierGenerator().generate( source, entity );
the getIdentifierGenerator()
returns POST_INSERT_INDICATOR (while with Oracle, it returns the class name of the entity to save)
Is there some configuration missing, or is it a bug of the Hibernate version?
Thanks for your help