小弟新做了一个保守的项目,用到了seasar框架,可谓是时间紧,任务重。怎奈刚接触,有许多地方还没弄明白,遂上来请教各位前辈,大神!!还望不吝赐教,小弟感激涕零!
闲话少絮,先把代码贴出来。
public enum TestEnumType {
ENUM_TOYOTA("01", "豊田"),
ENUM_HONDA("02", "本田");
TestEnumType(final String code, final String label) {
this.code = code;
this.label = label;
}
@PersistentValue
public String getCode() {
return code;
}
public String getLabel() {
return label;
}
}
@Entity
@Table(name = "test_table")
public final class TestTableEntity {
@Id
@Column(name = "test_type")
private TestEnumType testEnumType;
@Id
@Column(name = "using_flg")
private Boolean usingFlag;
@Lob
@Column(name = "test_content")
private String testContent;
get {...}
set {...}
}
public class TestDaoImpl implements TestDao {
@Resource(name = ConnectionTargetType.MASTER)
private JdbcManager jdbcManager;
@Override
public List<TestTableEntity> findById(@Nonnull final List<TestEnumType> testEnumType,
@Nullable final Boolean usingFlag) throws PersistenceRuntimeException {
return jdbcManager.from(TestTableEntity.class).where(
new SimpleWhere()
.in("testEnumType", testEnumType)
.eq("usingFlag", usingFlag))
.getResultList();
}
}
现调用Dao的findById方法,参数是TestEnumType.ENUM_HONDA,false
List list = testDao.findById(TestEnumType.ENUM_HONDA,false);
Log如下:
select T1_.test_type as C1_, T1_.using_flg as C2_, T1_.test_content as C3_ from test_table T1_ where (T1_.test_type in ([color=#FF0000]1[/color]) and T1_.using_flg = 0)
问题来了!!
T1_.test_type in (1) 这个地方,取的是TestEnumType.ENUM_HONDA 的序列,不是我想要的,
我想要的是 TestEnumType.ENUM_HONDA 的Code,也就是 T1_.test_type in ('02')
QA:
1.是什麽原因使得枚举类型的序列而不是code作为了检索条件?
2.这个应该怎么解决。
以上!
PS:欢迎大家围观,感谢您提出您的看法~~