Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating Annotations with params in JvmModelInferrer
Creating Annotations with params in JvmModelInferrer [message #1698165] Thu, 11 June 2015 19:18 Go to next message
Oliver Trosien is currently offline Oliver TrosienFriend
Messages: 2
Registered: January 2011
Junior Member
Hi,

I'm trying to generate JPA entities from my DSL, which heavily uses annotations. I'm stuck at creating annotations with named params, like shown below:

        accept(entity.toClass(entity.fullyQualifiedName)) [          
            // @Entity
            annotations += javax.persistence.Entity.annotationRef()
            // @Table(name="sqltable")
            annotations +=  javax.persistence.Table.annotationRef() // how to add the parameter?
   //...
}


How can I achieve this?

Thanks,
Oliver
Re: Creating Annotations with params in JvmModelInferrer [message #1698455 is a reply to message #1698165] Mon, 15 June 2015 19:04 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
https://www.eclipse.org/forums/index.php/m/1081054

Code: [Select all] [Show/ hide]
@Inject
TypesFactory typesFactory
...
annotations += javax.persistence.Table.annotationRef() => [
explicitValues += typesFactory.createJvmStringAnnotationValue() => [
values += entity.name.toUpperCase
operation = javax.persistence.Table.annotationRef().annotation.declaredOperations.findFirst[simpleName=="name"]
]
explicitValues += typesFactory.createJvmStringAnnotationValue() => [
values += "MY_SCHEMA"
operation = javax.persistence.Table.annotationRef().annotation.declaredOperations.findFirst[simpleName=="schema"]
]
]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Content assist in embedded editor
Next Topic:XText output language types
Goto Forum:
  


Current Time: Tue Mar 19 09:56:53 GMT 2024

Powered by FUDForum. Page generated in 0.02192 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top