如何在spring数据@Query中使用枚举

时间:2015-10-28 07:55:46

标签: spring spring-data spring-data-jpa

我试图将从枚举中检索到的静态值用作spring数据中import UIKit import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { var window: UIWindow? var manager = CLLocationManager() func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. manager.desiredAccuracy = kCLLocationAccuracyBest manager.delegate = self manager.requestAlwaysAuthorization() manager.startUpdatingLocation() return true } func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) { if UIApplication.sharedApplication().applicationState != .Active { NSLog("App is backgrounded. New location is %@", newLocation) } } ..... } 定义中的参数,但SpEL似乎无法正确解析:

@Query

@Query("SELECT o from AType o WHERE o.id = :id AND o.enumType = ?#{T(com.comap.EnumType).MY_TYPE.getId()}") Participant findTypedById(@Param("id") Long vacancyId); 返回com.comap.EnumType.MY_TYPE.getId()

但我得到的例外是:

2

如果我将SpEL前缀更改为Not all named parameters have been set: [1] [SELECT o from AType o WHERE o.id = :id AND o.enumType = ?1] ,请执行以下操作:

:#

然后我收到此错误:

@Query("SELECT o from AType o WHERE o.id = :id AND o.enumType = :#{T(com.comapny.EnumType).MY_TYPE.getId()}")
Participant findTypedById(@Param("id") Long vacancyId);

我做错了什么或不支持?

更新

将前缀更改为Not all named parameters have been set: [__$synthetic$__1] [SELECT o from AType o WHERE o.id = :id AND o.enumType = :__$synthetic$__1] 会导致此错误:

#

0 个答案:

没有答案