mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#580 - @Enumerated(EnumType.STRING) on Enum uses toString() rather than name()
This commit is contained in:
@@ -2,7 +2,16 @@ package com.avaje.tests.model.basic;
|
||||
|
||||
public enum MNonEnum {
|
||||
|
||||
BEGIN,
|
||||
END
|
||||
|
||||
BEGIN("B"),
|
||||
END("E");
|
||||
|
||||
String value;
|
||||
|
||||
MNonEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,26 @@ import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.basic.MNonEnum;
|
||||
import com.avaje.tests.model.basic.MNonUpdPropEntity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestFindWhereUsingEnumerated extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Ebean.find(MNonUpdPropEntity.class).where().eq("nonEnum", MNonEnum.BEGIN).findList();
|
||||
|
||||
|
||||
MNonUpdPropEntity e = new MNonUpdPropEntity();
|
||||
e.setNonEnum(MNonEnum.END);
|
||||
e.setName("TheNonEnumIsEnd");
|
||||
e.setNote("note");
|
||||
|
||||
Ebean.save(e);
|
||||
|
||||
MNonUpdPropEntity unique = Ebean.find(MNonUpdPropEntity.class).where()
|
||||
.eq("nonEnum", MNonEnum.END)
|
||||
.eq("name", "TheNonEnumIsEnd")
|
||||
.findUnique();
|
||||
|
||||
assertThat(unique).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user