Add to Favorites | Contact us | Chinese
Position:home>Technical tool>
EJB2
From;    Author:Stand originally

Bean of substance of the 2nd chapter
2.1.Brief introduction
Some the annotate standard that this chapter content covered EJB3.0 hypostatic Bean and Hibernate are special expanding.
2.2.Have map with EJB3 annotate
EJB3 is hypostatic now Bean is dinkum POJO. Actually this was conveyed with Hibernate abiding turn the idea with hypostatic same target. Their map is defined through JDK5.0 annotate (the XML description grammar in EJB3 standard still is done not have up to now come down finally surely) . Annotate cent is two parts, it is logistic map annotate and physical map annotate respectively, through logistic map annotate can depict object model, kind the relation between is waited a moment, and the Schema that physical map annotate described physics, watch, row, index is waited a moment. We mix the note that uses these two kinds of types in code lieutenant general below.
The API definition of EJB3 annotate is in Javax.persistence. Inside * bag. The IDE(with much and compatible JDK5 resembles Eclipse, intelliJ IDEA and Netbeans are waited a moment) what offerred annotate interface and property is automatic the function that finish. (These do not need IDE to offer special EJB3 to support module, because EJB3 annotate is JDK5 annotate of the standard)
Read guideline of JBoss EJB 3.0 to perhaps read Hibernate Annotations to check code to checked code in order to get more major unit that can run example.Hibernate Annotations to offer to demonstrate concrete example directly please, it is a good place that gets inspiration.
2.2.1.Statement substance Bean
Each abiding change POJO kind it is a hypostatic Bean, this can pass in kind @Entity annotate uses to undertake stating in the definition:
@EntityPublic Class Flight Implements Serializable {
Long Id;

@IdPublic Long GetId() {Return Id; }
Public Void SetId(Long Id) {This.id = Id; }
}

Through @Entity annotate will kind statement is a hypostatic Bean(namely abiding change POJO kind) , @Id annotate utter a word understands the label attribute of this substance Bean. Other map define be concealed type. This kind gives priority to body with concealed type map, for exceptional configuration with explicit map means is in new EJ3 standard be in very significant position, with the version previously photograph comparing had qualitative flight. Above in this paragraph of code: Flight kind map is expressed to Flight, use Id to be listed give priority to key to list.
Be opposite kind when having comment, you can choose the property to it or the method has comment, according to your choice, the visit type of Hibernate is Field or Property respectively. EJ3 standard asks to undertake annotate states on the element that visits in need, for example, if visit a type to be about to undertake on Getter method annotate states for Property, if visit a type,be about to undertake on the field annotate states for Field. Should avoid to mix as far as possible use type of these two kinds of visits. Hibernate judges visit type according to the position of @Id or @EmbeddedId.
Previous12 Next

About us | Legal Notices | Sitemap | Links | Partner