[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Fwd: Lost dali-dev message - [dali-dev] best way to add annotations to an Entity?
|
Hello, Tom
[I'm assuming you want to add an annotation to an *attribute*, not a *column*, as
state in your message.]
If you want to add an @Id annotation to a JPA attribute and you have access to the JPA
model, you can use the following:
JavaPersistentAttribute attribute = ...;
attribute.setMappingKey(IMappingKeys.ID_ATTRIBUTE_MAPPING_KEY, false);
This should add an @Id annotation to the appropriate field or method. If you want to
add other, non-JPA, annotations to your source, you can trace the code from this
method to see how Dali manipulates JDT annotations. It's not pretty.
Brian
> What would be the best way for me to programatically add some
>
> annotations to existing entities? Can I reuse some of the JPA
> models?
> For instance, from inside of a wizard, how could I set a primary
> key
> annotation on a column?
>
> It seems like there might be some JPA code that could be
> leveraged here.
> I see that JavaPersistentType updates the
> org.eclipse.jpa.core.java.mappings.JavaId column. Is there
> some way I
> can use Dali to assist in this (maybe the JpaCoreJavaMappingsFactory?)
> I
> could maybe just manually add the annotation myself, but I
> don't see an
> easy way to do this with eclipse JDT, and it wouldn't be as
> clean. Any
> ideas?
>
> Thanks
> Tom
>