ObjectDB ObjectDB

Possible issue for default id generator

#1

First all, congratulations to Objectdb team for the excellent work.

Possible issue for default id generator when strategy is sequence.

Error: Incomplete definition of auto value in field
MyTestCase$MyEntity.idgenerator name is missing (error 342)

Please find attached file MyTestCase.java lines 35 and 36:


@GeneratedValue(strategy=GenerationType.SEQUENCE)//, generator="seq")

@Id  @SequenceGenerator(name="seq") //workaround uncomment previous line

I am not an expert but in my opinion there is no default generator but the element generator is optional.

Thanks.

edit
delete
#2

In ObjectDB using the GenerationType.SEQUENCE strategy without specifying a sequence is meaningless, because with no sequence you should use one of the other strategies, so this error message is deliberate.

Technically the generator element is defined as optional (and you don't get a compilation error when it is omitted), because it is not required (and irrelevant) for strategies such as AUTO.

There are no strict rules in JPA for handling this annotation, so other JPA providers may provide a default sequence when no sequence is specified. In ObjectDB it makes sense to generate a runtime error, but maybe to ease porting applications from other JPA providers to ObjectDB a default should be provided in future versions.

Thank you for this notice.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.