mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge pull request #2935 from ebean-orm/feature/2915-invalid-id-mapping
#2915 - Failing test for - generator param of @GeneratedValue is not ignored when using GenerationType.AUTO on db where this uses identity
This commit is contained in:
3 files changed
+56
-3
No files matched your search
@@ -465,10 +465,9 @@ final class AnnotationFields extends AnnotationParser {
|
|||||||
if (!gen.generator().isEmpty()) {
|
if (!gen.generator().isEmpty()) {
|
||||||
// use a custom IdGenerator
|
// use a custom IdGenerator
|
||||||
PlatformIdGenerator idGenerator = generatedPropFactory.getIdGenerator(gen.generator());
|
PlatformIdGenerator idGenerator = generatedPropFactory.getIdGenerator(gen.generator());
|
||||||
if (idGenerator == null) {
|
if (idGenerator != null) {
|
||||||
throw new IllegalStateException("No custom IdGenerator registered with name " + gen.generator());
|
descriptor.setCustomIdGenerator(idGenerator);
|
||||||
}
|
}
|
||||||
descriptor.setCustomIdGenerator(idGenerator);
|
|
||||||
} else if (prop.getPropertyType().equals(UUID.class)) {
|
} else if (prop.getPropertyType().equals(UUID.class)) {
|
||||||
descriptor.setUuidGenerator();
|
descriptor.setUuidGenerator();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.tests.idkeys;
|
||||||
|
|
||||||
|
import io.ebean.DB;
|
||||||
|
import io.ebean.xtest.BaseTestCase;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.tests.idkeys.db.EaObject;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class TestEaObject extends BaseTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void insert() {
|
||||||
|
EaObject bean = new EaObject("fred");
|
||||||
|
DB.save(bean);
|
||||||
|
assertThat(bean.id()).isGreaterThan(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.tests.idkeys.db;
|
||||||
|
|
||||||
|
import io.ebean.Model;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "T_OBJECT")
|
||||||
|
public class EaObject extends Model {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "OBJECT_ID", nullable = false)
|
||||||
|
@GeneratedValue(
|
||||||
|
strategy = GenerationType.AUTO,
|
||||||
|
generator = "t_object_sequence_generator"
|
||||||
|
)
|
||||||
|
@SequenceGenerator(
|
||||||
|
name = "t_object_sequence_generator",
|
||||||
|
sequenceName = "OBJECT_ID_SEQ"
|
||||||
|
)
|
||||||
|
long id;
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
public EaObject(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user