0
I have a table that has ID defined as CREATE DEFAULT ID_Tabelas AS NEWID()
, that is, even if I use an Insert without the key, it will be generated automatically. How to make Hibernate recognize that the bank itself will generate the table key?
If I use the Annotations @GeneratedValue(strategy = GenerationType.AUTO)
or @GeneratedValue(strategy = GenerationType.IDENTITY)
, i get the following error:
SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-17) javax.faces.el.EvaluationException: org.hibernate.AssertionFailure: null identifier
If I use annotaion @GeneratedValue(strategy = GenerationType.TABLE)
, get the error:
SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-17) javax.faces.el.EvaluationException: org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String
The ID is denifido in the entity as:
@Id
@GeneratedValue(strategy = GenerationType.AUTO) //??
@Column(name = "id", length = 36, updatable = false, nullable = false)
private String id;
Take a look at this answer in the English OS, it might help you: https://stackoverflow.com/a/3079671/4730201
– Ricardo Pontual
which version of SQL Server ?
– LR10
@LR10 version 2008
– Ronie M
Didn’t work out ? with Quence?
– LR10
It worked, @Ricardopunctual. Thank you very much!
– Ronie M