में कनवर्ट नहीं करता है मेरे पास नीचे दी गई क्वेरी है जो कॉलम सूची में निरंतर चयन कर रही है और मैं स्ट्रिंग को उचित enum प्रकार में बदलने के लिए उपनाम ToBean की अपेक्षा कर रहा था।हाइबरनेट aliasToBean स्ट्रिंग को Enum
मैंने स्ट्रिंग के रूप में enum गुणों के साथ अन्य इकाइयों को मैप किया है और कोई समस्या नहीं है।
@SuppressWarnings("unchecked")
List<AssociatedEntity> fileList = queryUtil.createHQLQuery((
"select '" + AssociatedEntityTypeEnum.ASSOCIATED_ENTITY_TYPE_FILE + "' as associatedEntityType," +
" a.file2Id as id," +
" f.name as name" +
" from File f, Association a" +
" where f.id = :fileId" +
" and a.file1Id = f.id" +
" and a.associationType = :associationType"
))
.setParameter("fileId", fileId)
.setParameter("associationType", AssociationTypeEnum.ASSOCIATION_TYPE_FILE_FILE)
.setResultTransformer(Transformers.aliasToBean(AssociatedEntity.class))
.list();
यह सेम है:
23.11.2011 17:05:25 INFO [http-8080-2] (QueryUtil:createHQLQuery) - select 'ASSOCIATED_ENTITY_TYPE_FILE' as associatedEntityType, a.file2Id as id, f.name as name from File f, Association a where f.id = :fileId and a.file1Id = f.id and a.associationType = :associationType
23.11.2011 17:05:25 ERROR [http-8080-2] (BasicPropertyAccessor$BasicSetter:set) - IllegalArgumentException in class: com.twoh.dto.AssociatedEntity, setter method of property: associatedEntityType
23.11.2011 17:05:25 ERROR [http-8080-2] (BasicPropertyAccessor$BasicSetter:set) - expected type: com.twoh.dto.enums.AssociatedEntityTypeEnum, actual value: java.lang.String