0% found this document useful (0 votes)
683 views2 pages

Java Ee Reference Sheet

The document provides information on Java EE 7 annotations. It includes a legend and descriptions of various annotations for managing components, transactions, security, contexts and more in Java EE 7.

Uploaded by

vladimir_vozar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
683 views2 pages

Java Ee Reference Sheet

The document provides information on Java EE 7 annotations. It includes a legend and descriptions of various annotations for managing components, transactions, security, contexts and more in Java EE 7.

Uploaded by

vladimir_vozar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java EE 7 Annotations

Alternatives for management CDI JSF EJB CDI: [Link]


CMF @Inject @Named(value=) @Singleton T T T T T T TM TM T T T T

TM

@Interceptors ([Link][]) @ExcludeDefaultInterceptors @ExcludeClassInterceptors @AroundInvoke @AroundTimeout @Interceptor [only required with @InterceptorBinding]

EJB Types: [Link]


Session beans

TM M M M T

@Stateless (name=ClassName ) @Stateful(name=C lassName) @Singleton (name=ClassName ) @Local([Link][]) on EJB, @Local on interface @Remote([Link][]) on EJB, @Remote on interface @LocalBean @Asynchronous @Lock([[Link],READ]) @ConcurrencyManagement ([CONTAINER, BEAN]) @DependsOn (String[]) @Startup
Non-session beans

Security: [Link]
T T TM TM TM 1 @RunAs (String rolename) @DeclareRoles (String[]) @RolesAllowed(String[]) @PermitAll @DenyAll

CDI: [Link]
TMF TMF TMF TMF TMF @ApplicationScoped @SessionScoped @ConversationScoped @RequestScoped @Dependent

@MessageDriven (name=C lassName, activationConfig=@ActivationConfigProperty[]) @ActivationConfigProperty (propertyName=, propertyValue=)

CDI: [Link]
TMF TMF TMF MF @New(value=[Link]) @Alternative @Any @Produces, @Disposes

@ManagedBean (value=)

[in [Link].*]

Timeouts: [Link]
TM T M M @AccessTimeout (value=0,unit=MILLISECONDS) @StatefulTimeout(value=0,unit=MINUTES) @Timeout @Schedule(year=*, month=*, bimonthly=*, dayOfWeek=*, hour=0, minute=0, info=, persistent=true, timezone=) @Schedules (@Schedule[])

JSF management: [Link]


T T T T T T T F T @ManagedBean (name=, eager=false) @CustomScoped(value=) @NoneScoped @ApplicationScoped @SessionScoped @ViewScoped @RequestScoped @ManagedProperty (name=, value=) @ReferencedBean (name=)

Transaction: [Link]
T TM @TransactionManagement ([CONTAINER, BEAN]) @TransactionAttribute ([TransactionAttributeType. MANDATORY, REQUIRED, REQUIRES_NEW, SUPPORTS, NOT_SUPPORTED, NEVER]) @AfterBegin @BeforeCompletion @AfterCompletion

-- Possible source file layout for web app lib/ [potentially copied to /lib/ inside an EAR] `-- [Link] [jar shared between all modules] 2 src/java/ [potentially packaged as EJB-JAR inside EAR |-- [Link] or under |-- [Link] WEB-INF/classes/ |-- META-INF/ inside WAR] | |-- [Link] [for JPA config] | `-- [Link] [for deployment descriptors] `-- com/ `-- myBusiness/ |-- entities/ | `-- [Link] `-- [Link] src/webapp/ [potentially packaged as a WAR inside an EAR] 3 |-- WEB-INF/ | |-- [Link] [for CDI config] | |-- [Link] [for JSF config] | `-- [Link] [for Servlet 2.5 config] |-- resources/ | |-- css/ | | `-- [Link] EAR | `-- javascript/ class | `-- [Link] loader `-- [Link]
levels

Legend TCMF Annotation for Type, Constructor, Method, Field


VALUE Default Value

M M M

EJB injection: [Link]


TMF @EJB(name=, beanInterface=[Link], mappedName=, lookup=|| beanName=, description=) @EJBs(@EJB[])

Java EE 7 Annotations Cheat Sheet


Version 1.2 2005,2011 Philipp Meier Version 1.5 (2013-06-27) by Chris Rennie, based on Java EE 7 API Doc: EJB 3.2, JSF 2.2, JPA 2.1 [Link]/~rennie/
This work is licensed under the Creative Commons AttributionNonCommercial-ShareAlike 2.0 Germany License. To view a copy of this license, visit [Link] or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.

Lifecycle: [Link]
M M M M M @PostConstruct @PreDestroy @PostActivate @PrePassivate @Remove(retainIfException=false) [in [Link].*] [in [Link].*]

Resource injection: [Link]


TMF @Resource(name=, type=[Link], authenticationType= [[Link], APPLICATION], shareable=true, lookup=, mappedName=) @Resources (@Resource[])

Interceptors: [Link]

Persistence provider: [Link]


TMF @PersistenceContext (name=, unitName=,type= [[Link],EXTENDED], properties=@PersistenceProperty[]) @PersistenceContexts (@PersistenceContext[]) @PersistenceUnit(name=, unitName=) @PersistenceUnits (@PersistenceUnit[]) @PersistenceProperty (name=, value=) T @Cacheable(value=true)

TMF

@PrimaryKeyJoinColumn (name=THIS_PK , columnDefinition=, referencedColumnName= OTHER_FK) @PrimaryKeyJoinColumns (@PrimaryKeyJoinColumn[]) @JoinColumn (name=THIS_FK, table=, unique=false, nullable=true, insertable=true, updatable=true, columnDefinition=, referencedColumnName=OTHER_PK) @JoinColumns (@JoinColumn[]) @JoinTable(name=, schema=, catalog=, joinColumns={}, inverseJoinColumns={}, uniqueConstraints=@UniqueConstraint[]) @AssociationOverride (name=, joinTable= @JoinTable || joinColumns=@JoinColumn[]) @MapsId(value=propOrField) @OrderBy(value=) @OrderColumn (name=FIELD_ORDER,nullable=true, insertable=true, updatable=true, columnDefinition=)

TMF

@SequenceGenerator(name=, schema=, catalog=, sequenceName=, initialValue=0, allocationSize=50) @TableGenerator(name=, table=, schema=, catalog=, pkColumnName=, valueColumnName=, pkColumnValue=, initialValue=0, allocationSize=50, uniqueConstraints=@UniqueConstraint[])

TMF MF

TMF

T TMF T

MF MF

Embedded objects: [Link]


T MF MF @Embeddable @EmbeddedId @Embedded

Object mapping: [Link]


T T T @Entity (name=) @Table(name=, schema=, catalog=, uniqueConstraints=@UniqueConstraint[]) @SecondaryTable(name=, schema=, catalog=, pkJoinColumns=@PrimaryKeyJoinColumn[], uniqueConstraints=@UniqueConstraint[]) @SecondaryTables (@SecondaryTable[]) @UniqueConstraint(columnNames=String[], name=) T TMF TMF @IdClass ([Link]) @Access (value=[[Link], PROPERTY]) @AttributeOverride(name=, column=@Column)

TMF MF MF MF

Collections and Maps: [Link]


MF MF MF @CollectionTable (name=, schema=, catalog=, joinColumns={}, uniqueConstraints={}) @ElementCollection (targetClass= [Link] , fetch=[[Link], EAGER]) @MapKeyColumn (name=FK, table=, unique=false, nullable=true, insertable=true, updatable=true, columnDefinition=, length=255, precision=0, scale=0) @MapKeyJoinColumn (name=FK, table=, unique=false, nullable=true, insertable=true, updatable=true, columnDefinition=, referencedColumnName=OTHER_PK) @MapKeyJoinColumns (@MapKeyJoinColumn[]) @MapKey(propOrField) @MapKeyClass ([Link]) @MapKeyEnumerated ([[Link],STRNG]) @MapKeyTemporal([[Link], TIME, TIMESTAMP])

Queries: [Link]
T T T T @NamedQuery (name=, query=JPQL..., hints= @QueryHint[], lockMode=...) @NamedQueries (@NamedQuery[]) @NamedNativeQuery (name=, query=SQL..., resultClass=[Link], hints=..., lockMode=...) @NamedNativeQueries (@NamedQuery[]) @QueryHint(name=, value=)

MF

Prop/Field mapping: [Link]


MF MF @Id @Column(name=, table=, unique=false, nullable=true, insertable=true, updatable=true, columnDefinition=, length=255, precision=0, scale=0) @Basic(fetch=[LAZY, EAGER], optional=true) @Enumerated([[Link],STRING]) @Temporal([[Link], TIME, TIMESTAMP]) @Transient @Lob @Version !! Near-redundancy:
'nullable' describes DB fields 'optional' describes entity properties

MF MF MF MF MF

SqlResultSet mapping: [Link]


T T @SqlResultSetMappings (@SqlResultSetMapping[]) @SqlResultSetMapping (name=, entities= @EntityResult[], columns=@ColumnResult[]) @EntityResult(entityResult=[Link], disriminatorColumn=, fields=@FieldResult[]) @FieldResult(name=, column=) @ColumnResult(name=)

MF MF MF MF MF MF

JPA Lifecycle: [Link]


M M M M M M M @PrePersist @PostPersist @PostLoad @PreUpdate @PostUpdate @PreRemove @PostRemove [C] [C] [R] [U] [U] [D] [D]

Relationship mapping: [Link]


MF @OneToOne(targetEntity= [Link], cascade={[Link], DETACH, MERGE, PERSIST, REFRESH, REMOVE}, fetch=[[Link], EAGER], optional=true, mappedBy=propOrField, orphanRemoval=false) @OneToMany (targetEntity=[Link] , cascade={...}, fetch=[LAZY,EAGER], mappedBy=, orphanRemoval=false) @ManyToOne(targetEntity=[Link] , cascade={...}, fetch=[LAZY,EAGER], optional=true) @ManyToMany (targetEntity=[Link] , cascade={...}, fetch=[LAZY,EAGER], mappedBy=)

Inheritance: [Link]
T T T T @MappedSuperclass @Inheritance([InheritanceType. SINGLE_TABLE, TABLE_PER_CLASS, JOINED]) @DiscriminatorValue (value=) @DiscriminatorColumn (name=DTYPE, discriminatorType=[STRING,CHAR,INTEGER], columnDefinition=, length=31)

Listeners: [Link]
T T T See also @EntityListeners ([Link][]) @ExcludeDefaultListeners @ExcludeSuperclassListeners [Link] [Link]

MF

MF MF

Generators: [Link]
MF @GeneratedValue(generator=, strategy= [[Link],IDENTITY,SEQUENCE,TABLE])

Java EE 7 Annotations
Alternatives for management
CDI
JSF
EJB
CDI: javax.inject
CMF
@Inject
@Named(value=””)
@Singleton
CDI:
Persistence provider: javax.persistence
TMF
@PersistenceContext(name=””, unitName=””,type= 
[PersistenceContextType.TRANSACTI

You might also like