Java Annotations with No Target
Perhaps you would expect every Java annotation to have one or multiple targets, indicating where it can be applied, either on a class, method, field, or some combination. It's correct for the most part, but it also turns out some java annotations have no target. Their target()
field is an empty array. For example,
javax.ejb.ActivationConfigProperty:
@Target(value={})
@Retention(value=RUNTIME)
public @interface ActivationConfigPropertyjavax.persistence.EntityResult
@Target(value={})
@Retention(value=RUNTIME)
public @interface EntityResult
@ActivationConfigProperty
can only be used inside @javax.ejb.MessageDriven
to specify properties for the Message-Driven Bean (MDB):@MessageDriven(name="MessageBean",
activationConfig = {
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Topic"),
@ActivationConfigProperty(propertyName="acknowledgeMode",
propertyValue="Auto-acknowledge"),
@ActivationConfigProperty(propertyName="subscriptionDurability",
propertyValue="Durable"),
@ActivationConfigProperty(propertyName="messageSelector",
propertyValue="name='java' AND bugs < 1")
})
public class MessageBean implements MessageListener {
...
}
@javax.persistence.EntityResult
can only be used as nested annotation inside @javax.persistence.SqlResultSetMapping
. Here is a more complex example from its java doc, with 3 nested annotations at 3 different levels:@SqlResultSetMapping(name="OrderResults",
entities={
@EntityResult(entityClass=com.acme.Order.class, fields={
@FieldResult(name="id", column="order_id"),
@FieldResult(name="quantity", column="order_quantity"),
@FieldResult(name="item", column="order_item")})},
columns={
@ColumnResult(name="item_name")}
)
Tags:
3 comments:
Great and Useful Article.
Online Java Training
Java Online Training India
Java Online Course
Java EE course
Java EE training
Best Recommended books for Spring framework
Java Interview Questions
Java Course in Chennai
Java Online Training India
Your work is time-consuming but you know that it is well done!
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
Internet Of Things training in electronic city
Post a Comment