问题描述
我怎样才能得到一个域类的mapWith属性?
How can I get mapWith property of a domain class?
我试过domainClass.mapWith,因为它是域类的一个静态属性。
我也尝试了mappedBy,但它是一个不同的上下文。
I tried domainClass.mapWith as it's a static property of domain class.It didn't work.I also tried mappedBy but it's a different context.
任何关于如何从GrailsDomainClass获取mapWith值的想法
Any idea on how can i get mapWith value from GrailsDomainClass
以下是我的域名: -
Below is my domain:-
public class Ticket {
String id
List<Long> productInstanceId
static hasMany = [productInstanceId:Long]
static mapWith = "none"
}
推荐答案
如果您正在直接检查特定域,那么您可以使用域类获取静态属性。在你的情况下,它会是 Ticket.mapWith
或 Ticket.class.mapWith
。
If you are doing a direct check on a particular domain then you can fetch the static property with domain class. In your case it would be Ticket.mapWith
or Ticket.class.mapWith
.
如果您正在进行动态检查,那么您可以借助 DefaultGrailsDomainClass
来找到它。
If you are doing a dynamic check then you can find it with the help of DefaultGrailsDomainClass
.
GrailsDomainClass aClass = new DefaultGrailsDomainClass(clazz)
aClass.mappingStrategy
这篇关于从GrailsDomainClass grails获取mapWith静态域字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!