0% found this document useful (0 votes)
1K 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)
1K 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
You are on page 1/ 2

Java EE 7 Annotations

Alternatives for management CDI JSF EJB CDI: javax.inject


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

TM

@Interceptors (Class.class[]) @ExcludeDefaultInterceptors @ExcludeClassInterceptors @AroundInvoke @AroundTimeout @Interceptor [only required with @InterceptorBinding]

EJB Types: javax.ejb


Session beans

TM M M M T

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

Security: javax.annotation.security
T T TM TM TM 1 @RunAs (String rolename) @DeclareRoles (String[]) @RolesAllowed(String[]) @PermitAll @DenyAll

CDI: javax.enterprise.context
TMF TMF TMF TMF TMF @ApplicationScoped @SessionScoped @ConversationScoped @RequestScoped @Dependent

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

CDI: javax.enterprise.inject
TMF TMF TMF MF @New(value=Class.class) @Alternative @Any @Produces, @Disposes

@ManagedBean (value=)

[in javax.annotation.*]

Timeouts: javax.ejb
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: javax.faces.bean


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: javax.ejb
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] `-- extra.jar [jar shared between all modules] 2 src/java/ [potentially packaged as EJB-JAR inside EAR |-- ValidationMessages.properties or under |-- JSFStrings.properties WEB-INF/classes/ |-- META-INF/ inside WAR] | |-- persistence.xml [for JPA config] | `-- ejb-jar.xml [for deployment descriptors] `-- com/ `-- myBusiness/ |-- entities/ | `-- Entities.java `-- EJBs.java src/webapp/ [potentially packaged as a WAR inside an EAR] 3 |-- WEB-INF/ | |-- beans.xml [for CDI config] | |-- faces-config.xml [for JSF config] | `-- web.xml [for Servlet 2.5 config] |-- resources/ | |-- css/ | | `-- standard.css EAR | `-- javascript/ class | `-- standard.js loader `-- jsfpages.xhtml
levels

Legend TCMF Annotation for Type, Constructor, Method, Field


VALUE Default Value

M M M

EJB injection: javax.ejb


TMF @EJB(name=, beanInterface=Interface.class, 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 www.physics.usyd.edu.au/~rennie/
This work is licensed under the Creative Commons AttributionNonCommercial-ShareAlike 2.0 Germany License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/de/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.

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

Resource injection: javax.annotation


TMF @Resource(name=, type=Class.class, authenticationType= [AuthenticationType.CONTAINER, APPLICATION], shareable=true, lookup=, mappedName=) @Resources (@Resource[])

Interceptors: javax.interceptor

Persistence provider: javax.persistence


TMF @PersistenceContext (name=, unitName=,type= [PersistenceContextType.TRANSACTION,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: javax.persistence


T MF MF @Embeddable @EmbeddedId @Embedded

Object mapping: javax.persistence


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 (Class.class) @Access (value=[AccessType.FIELD, PROPERTY]) @AttributeOverride(name=, column=@Column)

TMF MF MF MF

Collections and Maps: javax.persistence


MF MF MF @CollectionTable (name=, schema=, catalog=, joinColumns={}, uniqueConstraints={}) @ElementCollection (targetClass= void.class , fetch=[FetchType.LAZY, 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 (Class.class) @MapKeyEnumerated ([EnumType.ORDINAL,STRNG]) @MapKeyTemporal([TemporalType.DATE, TIME, TIMESTAMP])

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

MF

Prop/Field mapping: javax.persistence


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([EnumType.ORDINAL,STRING]) @Temporal([TemporalType.DATE, TIME, TIMESTAMP]) @Transient @Lob @Version !! Near-redundancy:
'nullable' describes DB fields 'optional' describes entity properties

MF MF MF MF MF

SqlResultSet mapping: javax.persistence


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

MF MF MF MF MF MF

JPA Lifecycle: javax.persistence


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

Relationship mapping: javax.persistence


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

Inheritance: javax.persistence
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: javax.persistence
T T T See also @EntityListeners (Class.class[]) @ExcludeDefaultListeners @ExcludeSuperclassListeners http://www.oracle.com/technetwork/middleware/ias/top link-jpa-annotations-096251.html

MF

MF MF

Generators: javax.persistence
MF @GeneratedValue(generator=, strategy= [GenerationType.AUTO,IDENTITY,SEQUENCE,TABLE])

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy