zero value returned by Hibernate save() method (with Sql Server database)

Viewed 30

I am facing an issue with Spring MVC and Hibernate 4.2.1.

With Oracle DB connection, when save() method is performed I obtain a Long value that describes the ID of the saved record. Using a Sql Server instance, otherwise, the save() returns always a Long with 0 value.

I've printed the query in the console and I've noticed that the ID field is missing (when the operation is performed on Oracle, the ID field is present).

Following, the snippet of the entity class with the highlight on ID column:

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "seq")
    @SequenceGenerator(name="seq", sequenceName="SEQ_PEZZI") 
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;

The field type in the database is bigint.

I've also tried to change the GenerationType with IDENTITY without success (the type SEQUENCE seems not supported in SQL Server...)

0 Answers
Related