You are on page 1of 2

M @AroundTimeout

Java EE 6 Annotations Bean Types: javax.ejb TM @ExcludeDefaultInterceptors


T @Stateless(name=”ClassName”) M @ExcludeClassInterceptors
Alternatives for EJB management
T @Stateful(name=”ClassName”)
CDI JSF EJB3 Security: javax.annotation.security
T @Singleton(name=”ClassName”)
T @MessageDriven(name=”ClassName”, T @RunAs(String rolename)
activationConfig=@ActivationConfigProperty[]) T @DeclareRoles(String[])
CDI: javax.inject
@ActivationConfigProperty(propertyName=””, TM @RolesAllowed(String[])
@Named(value=””) propertyValue=””) TM @PermitAll
CMF @Inject T @Local(Class.class[]) TM @DenyAll
T @Remote(Class.class[]) -- Possible source file layout for web app –
CDI: javax.enterprise.context T @LocalBean 1 lib/ [potentially copied to /lib/ inside an EAR]
TMF @ApplicationScoped `-- extra.jar [if jar shared between all modules]
TM @Asynchronous
TMF @SessionScoped 2 src/java/ [potentially packaged as EJB-JAR inside EAR -
TM @Lock([LockType.WRITE,READ]) |-- ValidationMessages.properties or under
TMF @ConversationScoped
T @ConcurrencyManagement([CONTAINER, BEAN]) |-- META-INF/ WEB-INF/classes inside WAR]
TMF @RequestScoped | |-- persistence.xml [if JPA]
T @DependsOn(String[])
TMF @Dependent | `-- ejb-jar.xml [if deployment descriptors]
T @Startup `-- com/
`-- myBusiness/
CDI: javax.enterprise.inject Timeouts: javax.ejb |-- entities/
TMF @New(value=Class.class) | `-- Entities.java
TM @AccessTimeout(value=”0”,unit=MILLISECONDS)
TMF @Alternative |-- resources/
T @StatefulTimeout(value=”0”,unit=MILLISECONDS) | `-- messages.properties
TMF @Any
M @Timeout `-- EJBs.java
MF @Produces 3 web/ [potentially packaged as a WAR inside an EAR]
M @Schedule(year=”*”, month=”*”, bimonthly=”*”,
dayOfWeek=”*”, hour=”0”, minute=”0”, info=””, |-- WEB-INF/
JSF management: javax.faces.bean persistent=true, timezone=””) | |-- beans.xml [if CDI]
| |-- faces-config.xml [if JSF]
T @ManagedBean(name=””, eager=false) M @Schedules(@Schedule[]) | `-- web.xml [if Servlet 2.5]
T @CustomScoped(value=””) |-- resources/
T @ApplicationScoped Transaction: javax.ejb | |-- css/
EAR | | `-- standard.css
T @SessionScoped T @TransactionManagement([CONTAINER, BEAN]) class | `-- javascript/
T @ViewScoped TM @TransactionAttribute([TransactionAttributeType. loader | `-- standard.js
levels
T @RequestScoped MANDATORY, REQUIRED, REQUIRES_NEW, `-- jsfpages.xhtml
SUPPORTS, NOT_SUPPORTED, NEVER])
T @NoneScoped
M @AfterBegin
F @ManagedProperty(name=””, value=””)
M @BeforeCompletion Legend
T @ReferencedBean(name=””)
M @AfterCompletion TCMF Annotation for Type, Constructor, Method, Field
VALUE Default Value
EJB3 injection: javax.ejb
TMF @EJB(name=””, beanInterface=Interface.class,
EJB Lifecycle: javax.ejb
mappedName=””, lookup=””|| beanName=””, M @Remove(retainIfException=[true,false])
description=””)
Java EE 6 Annotations Cheat Sheet
M @PostConstruct [in javax.annotation.*]
Version 1.3 (2011-11-09), based on Java EE 6 API Doc
T @EJBs(@EJB[]) M @PreDestroy [in javax.annotation.*]
©2005,2011 Philipp Meier – www.fnogol.de
M @PostActivate
EJB3 injection: javax.annotation 2011 Updated for EJB 3.1, JSF 2.0, JPA 2.0 by Chris Rennie
M @PrePassivate Report errors to c.rennie@physics.usyd.edu.au
T @ManagedBean(value=””)
This work is licensed under the Creative Commons Attribution-
TMF @Resource(name=””, type=Class.class, Interceptors: javax.interceptor NonCommercial-ShareAlike 2.0 Germany License. To view a copy of this
authenticationType= license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/de/ or
[AuthenticationType.CONTAINER, APPLICATION], T @Interceptor send a letter to Creative Commons, 543 Howard Street, 5th Floor, San
shareable=true, lookup=””, mappedName=””) TM @Interceptors(Class.class[]) Francisco, California, 94105, USA.
T @Resources(@Resource[]) M @AroundInvoke
TMF @PrimaryKeyJoinColumn(name=”THIS_PK”, TMF @SequenceGenerator(name=””, schema=””,
Persistence provider: javax.persistence columnDefinition=””, referencedColumnName= catalog=””, sequenceName=””, initialValue=0,
TMF @PersistenceContext(name=””, unitName=””,type= ”OTHER_FK”) allocationSize=50)
[PersistenceContextType.TRANSACTION,EXTENDED], TMF @PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn[]) TMF @TableGenerator(name=””, table=””, schema=””,
properties=@PersistenceProperty[]) MF @JoinColumn(name=”THIS_FK”, table=””, catalog=””, pkColumnName=””,
T @PersistenceContexts(@PersistenceContext[]) unique=false, nullable=true, insertable=true, valueColumnName=””, pkColumnValue=””,
updatable=true, columnDefinition=””, initialValue=0, allocationSize=50,
TMF @PersistenceUnit(name=””, unitName=””)
referencedColumnName=”OTHER_PK”) uniqueConstraints=@UniqueConstraint[])
T @PersistenceUnits(@PersistenceUnit[])
MF @JoinColumns(@JoinColumn[])
@PersistenceProperty(name=””, value=””) Embedded objects: javax.persistence
MF @JoinTable(name=””, schema=””, catalog=””,
T @Cacheable(value=true) T @Embeddable
joinColumns={}, inverseJoinColumns={},
uniqueConstraints=@UniqueConstraint[]) MF @EmbeddedId
Object mapping: javax.persistence
TMF @AssociationOverride(name=””, joinTable= MF @Embedded
T @Entity(name=””) @JoinTable || joinColumns=@JoinColumn[])
T @Table(name=””, schema=””, catalog=””, MF @MapsId(value=”propOrField”) Collections and Maps: javax.persistence
uniqueConstraints=@UniqueConstraint[])
MF @OrderBy(value=””) MF @CollectionTable(name=””, schema=””, catalog=””,
T @SecondaryTable(name=””, schema=””, catalog=””, joinColumns={}, uniqueConstraints={})
pkJoinColumns=@PrimaryKeyJoinColumn[], MF @OrderColumn(name=”FIELD_ORDER”,nullable=true,
uniqueConstraints=@UniqueConstraint[]) insertable=true, updatable=true, columnDefinition=””) MF @ElementCollection(targetClass=void.class,
fetch=[FetchType.LAZY, EAGER])
T @SecondaryTables(@SecondaryTable[])
Queries: javax.persistence MF @MapKeyColumn(name=”FK”, table=””,
@UniqueConstraint(columnNames=String[],
unique=false, nullable=true, insertable=true,
name=””) T @NamedQuery(name=””, query=”JPQL...”, hints= updatable=true, columnDefinition=””, length=255,
T @IdClass(Class.class) @QueryHint[], lockMode=...) precision=0, scale=0)
TMF @Access(value=[AccessType.FIELD, PROPERTY]) T @NamedQueries(@NamedQuery[]) MF @MapKeyJoinColumn(name=”FK”, table=””,
TMF @AttributeOverride(name=””, column=@Column) T @NamedNativeQuery(name=””, query=”SQL...”, unique=false, nullable=true, insertable=true,
resultClass=void.class, hints=..., lockMode=...) updatable=true, columnDefinition=””,
T @NamedNativeQueries(@NamedQuery[]) referencedColumnName=”OTHER_PK”)
Field mapping: javax.persistence
@QueryHint(name=””, value=””) MF @MapKeyJoinColumns(@MapKeyJoinColumn[])
MF @Column(name=””, table=””, unique=false,
nullable=true, insertable=true, updatable=true, MF @MapKey(”propOrField”)
columnDefinition=””, length=255, precision=0, SqlResultSet mapping: javax.persistence MF @MapKeyClass(Class.class)
scale=0)
T @SqlResultSetMappings(@SqlResultSetMapping[]) MF @MapKeyEnumerated([EnumType.ORDINAL,STRNG])
MF @Id
T @SqlResultSetMapping(name=””, entities= MF @MapKeyTemporal([TemporalType.DATE, TIME,
MF @Basic(fetch=[LAZY, EAGER], optional=true) TIMESTAMP])
@EntityResult[], columns=@ColumnResult[])
MF @Enumerated([EnumType.ORDINAL,STRING])
@EntityResult(entityResult=Class.class,
MF @Temporal([TemporalType.DATE, TIME, TIMESTAMP]) disriminatorColumn=””, fields=@FieldResult[]) JPA Lifecycle: javax.persistence
MF @Transient @FieldResult(name=””, column=””) M @PrePersist [C]
MF @Lob @ColumnResult(name=””) M @PostPersist [C]
MF @Version M @PostLoad [R]
Inheritance: javax.persistence M @PreUpdate [U]
Relationship mapping: javax.persistence T @MappedSuperclass M @PostUpdate [U]
MF @OneToOne(targetEntity=void.class, T @Inheritance([InheritanceType.SINGLE_TABLE, M @PreRemove [D]
cascade={CascadeType.ALL, DETACH, MERGE, TABLE_PER_CLASS, JOINED]) M @PostRemove [D]
PERSIST, REFRESH, REMOVE},
T @DiscriminatorValue(value=””)
fetch=[FetchType.LAZY, EAGER], optional=true,
mappedBy=”propOrField”, orphanRemoval=false) T @DiscriminatorColumn(name=”DTYPE”, Listeners: javax.persistence
discriminatorType=[STRING,CHAR,INTEGER], T @EntityListeners(Class.class[])
MF @OneToMany(targetEntity=void.class ,
columnDefinition=””, length=31)
cascade={...}, fetch=[...], mappedBy=””, T @ExcludeDefaultListeners
orphanRemoval=false) T @ExcludeSuperclassListeners
Generators: javax.persistence
MF @ManyToOne(targetEntity=void.class,
cascade={...}, fetch=[...], optional=true) MF @GeneratedValue(generator=””, strategy= See http://www.oracle.com/technetwork/middleware/ias/top
[GenerationType.AUTO,IDENTITY,SEQUENCE,TABLE]) also link-jpa-annotations-096251.html
MF @ManyToMany(targetEntity=void.class,
cascade={...}, fetch=[...], mappedBy=””)

You might also like