| Re: [eclipselink-users] [OT]-ish Reading Annotation Data |
|
Roger, Tim, Vackar, Hi, providing runtime API functionality to inspect the both JPA annotation API and the XML mapping API is very useful functionality that I find particularly interesting. There is work in the JPA 2.0 specification that exposes non-native JPA annotations via the Metamodel or Criteria API. For details on this work, you may take a look at JSR-317 (JPA 2.0) where an implementation of this API is in development by this team. See the upcoming PFD of the specification to be released at http://jcp.org/aboutJava/communityprocess/edr/jsr317/index.html Also, I just talked with Chris about this issue and we should be able to use native EclipseLink API to access the DatabaseField just like we do when leveraging the metadata API for metamodel processing. Roger wrote: An API like you mention is being released with EclipseLink 2.0.On Monday 28 September 2009 16:26:00 Tim Hollosy wrote: See the RI for EJB 3.1/JPA 2.0 where the Metamodel API exposes the entity annotation API and the XML mapping API as one unified "metadata" type-safe API - this model is used both by the canonical processor to dynamically generate metamodel classes from source at design time, and by the Criteria API used to query the metamodel at runtime. All of these tools are available on the EclipseLink 2.0 trunk and will be released as part of the RI for EJB 3.1/JPA 2.0. http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0 In answer to the @Column length annotation field - i think this would be a very good extension of the API once the specification has been finalized. The granularity of the JPA Metamodel may not capture all available JPA annotation details. We could add more annotation details on the elementType field of the JPA 2.0 Attribute - but outside of the JPA specification, more details are available via the mapping or descriptor. computersAttribute SetAttributeImpl<X,V> (id=194) elementType EntityTypeImpl<X> (id=121) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Computer) (id=80) managedType EntityTypeImpl<X> (id=131) javaClass Class<T> (org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) (id=88) mapping OneToManyMapping (id=203) We welcome any suggestions on extending the JPA 2.0 API implementation. I will add extended annotation access to the design page at http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api RogerV <roger.varley@xxxxxxxxxxxxxx> 28/09/2009 14:16 >>> Is there a way of retrieving annotation data from an entity? Specifically I'm using the @Column(length=) annotation in a Struts 2 web app. It would be useful if I could read this data and use it to validate the incoming field length and to use it on the result to set the width of the input field. thank you michael The only reason that I think why people would think you mad for what, to me, seems a perfectly reasonable idea, is that people have been there, done that and it has been shown to be A Bad Idea(Tm). I'd be interested in comments before I attempt to go down this route. I'm talking specifically about using entities in a web-app where I need to validate the length of fields returned before trying to insert/update the database. I'd also like to make the column length available to the web framework (in this instance Struts 2) so I can set the size of the input/display elements to match their definition where appropriate. Regards _______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users |