📄 amber.xtp
字号:
}</def></s3><s3 title="@TableGenerator"><p>Specifies a secondary table to be used for generating keys.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>name</td> <td>The amber name of the generator table</td> <td>required</td></tr><tr> <td>table</td> <td>The SQL name of the generator table</td> <td><var>name</var></td></tr><tr> <td>catalog</td> <td>The SQL catalog of the generator table</td> <td></td></tr><tr> <td>schema</td> <td>The SQL schema of the generator table</td> <td></td></tr><tr> <td>pkColumnName</td> <td>The SQL column name for the primary key name</td> <td></td></tr><tr> <td>valueColumnName</td> <td>The SQL column name for the value</td> <td></td></tr><tr> <td>pkColumnName</td> <td>The SQL column name for the primary key's value</td> <td></td></tr><tr> <td>initialValue</td> <td>The initial value to seed the generator</td> <td>0</td></tr><tr> <td>allocationSize</td> <td>The number of values to increment by for each allocation</td> <td>50</td></tr><tr> <td>uniqueConstraints</td> <td>Extra uniqueness constraints when creating the table</td> <td></td></tr></deftable><def title="javax.persistence.TableGenerator">@Target({TYPE, METHOD, FIELD})@Retention(RUNTIME)public @interface TableGenerator { String name(); String table() default ""; String catalog() default ""; String schema() default ""; String pkColumnName() default ""; String valueColumnName() default ""; String pkColumnValue() default ""; int initialValue() default 0; int allocationSize() default 50; UniqueConstraint []uniqueConstraints() default {};}</def></s3></s2><s2 title="Property Annotations"><s3 title="@Basic"><p>Marks a field as a persistent field.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>fetch</td> <td>EAGER or LAZY fetching</td><td>FetchType.EAGER</td></tr><tr> <td>optional</td> <td>if true, the column may be null</td> <td>true</td></tr></deftable><def title="javax.persistence.Basic">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Basic { FetchType fetch() default EAGER; boolean optional() default true;}</def><p>The fetch types are:</p><ul><li>EAGER - fetch the field when the bean is loaded</li><li>LAZY - fetch the field only when the field is used</li></ul><example title="Example: string property ">@Entitypublic class Course { @Basic public String getName() ...}</example><example title="Example: lazy-loaded property ">@Entitypublic class Course { @Basic(fetch=FetchType.LAZY) public String getMassiveText() ...}</example></s3><s3 title="@Column"><p>Specifies the field's SQL column name as well as any CREATE TABLEproperties for auto generation.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>name</td> <td>The SQL name of the column</td> <td>the field name</td></tr><tr> <td>unique</td> <td>True for UNIQUE columns</td> <td>false</td></tr><tr> <td>nullable</td> <td>False for IS NOT NULL columns</td> <td>true</td></tr><tr> <td>insertable</td> <td>True if column is inserted on as SQL <code>INSERT</code> call</td> <td>true</td></tr><tr> <td>updatable</td> <td>True if column is updated when the field is modified</td> <td>false</td></tr><tr> <td>columnDefinition</td> <td>SQL to create the column in a CREATE TABLE</td> <td>none</td></tr><tr> <td>table</td> <td>specified if column is stored in a secondary table</td> <td>none</td></tr><tr> <td>length</td> <td>the default length for a VARCHAR for a CREATE TABLE</td> <td>255</td></tr><tr> <td>precision</td> <td>the default length for a number definition for a CREATE TABLE</td> <td>0</td> </tr><tr> <td>scale</td> <td>the default length for a number definition for a CREATE TABLE</td> <td>0</td></tr></deftable><def title="javax.persistence.Column">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Column { String name() default ""; boolean unique() default false; boolean nullable() default true; boolean insertable() default true; boolean updateable() default true; String columnDefinition() default ""; String table() default ""; int length() default 255; int precision() default 0; int scale() default 0;}</def><example title="Example: @Column for a string property ">@Entitypublic class Course { @Basic @Column(name="MY_NAME", unique=true, nullable=false, length=32) public String getName() ...}</example></s3><s3 title="@Embedded"><p>Marks a field as containing an embeddable value. The field's valuewill be a class marked as @Embeddable. Applications can use @Embeddedfields to gather columns into meaningful groups.</p><def title="javax.persistence.Embedded">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Embedded {}</def></s3><s3 title="@EmbeddedId"><p>Marks a field as a primary key with a embedded class. The field'svalue class must be marked with <code>@Embeddable</code>. Applications canuse <code>@EmbeddedId</code> to implement compound keys.</p><def title="javax.persistence.EmbeddedId">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface EmbeddedId {}</def></s3><s3 title="@Enumerated"><p>Marks a field as containing an enumerated value.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>value</td> <td>Specifies whether the enum's ORDINAL or STRING representation should be saved in the database.</td> <td>ORDINAL</td></tr></deftable><def title="javax.persistence.Enumerated">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Enumerated { EnumType value() default ORDINAL;}</def></s3><s3 title="@GeneratedValue"><p>Used with @Id to specify a generator for automatic key generation when newobjects are created.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>generator</td> <td>The sequence or table generator name</td> <td>${table}_cseq</td></tr><tr> <td>strategy</td> <td>The auto-generation type: TABLE, SEQUENCE, IDENTITY or AUTO</td> <td>AUTO</td></tr></deftable><p>The generator types are:</p><ul><li>IDENTITY - the database supplies the new key, e.g. auto_increment, SERIAL, or IDENTITY</li><li>SEQUENCE - use a SEQUENCE type to generate the key</li><li>TABLE - use a @TableGenerator for the key</li><li>AUTO - choose the generator based on the database<ul> <li>MySQL - IDENTITY using auto_increment</li> <li>Resin - IDENTITY using auto_increment</li> <li>Postgres - SEQUENCE</li> <li>Oracle - SEQUENCE</li></ul></li></ul><def title="javax.persistence.GeneratedValue">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface GeneratedValue { GenerationType strategy() default AUTO; String generator() default "";}</def><p>For SEQUENCE and TABLE, Resin will create the sequencename as "${table}_cseq".</p><example title="Example: autoincrement generation">import javax.persistence.*;@Entitypublic class Course { @Id @GeneratedValue public long getId() ...}</example><example title="Example: sequence generation">import javax.persistence.*;@Entitypublic class Course { @Id @GeneratedValue(strategy=GeneratorType.AUTO generator="COURSE_SEQ") public long getId() ...}</example></s3><s3 title="@Id"><p>Marks a field as a primary key. The <code>@Id</code>may be used in combination with <code>@GeneratedValue</code> to specify a generator for automatic key generation when newobjects are created.</p><def title="javax.persistence.Id">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Id {}</def><p>The default column name is "ID".</p><example title="Example: automatic generation">import javax.persistence.*;@Entitypublic class Course { @Id @Column(name="t_id") @GeneratedValue public long getId() ...}</example></s3><s3 title="@Lob"><p>Marks a field as containing a large blob value.</p><def title="javax.persistence.Lob">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Lob {}</def></s3><s3 title="@Temporal"><p>Marks a field as a time-based value.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>value</td> <td>The SQL type used for the field value: DATE, TIME or TIMESTAMP</td> <td>TIMESTAMP</td></tr></deftable><def title="javax.persistence.Temporal">@Target({METHOD, FIELD})@Retention(RUNTIME)public @interface Temporal { TemporalType value() default TIMESTAMP;}</def></s3><s3 title="@Transient"><p><code>@Transient</code> makes a field non-persistent.<code>@Transient</code> fields work like the <code>transient</code>annotation to prevent properties being saved.</p><def title="javax.persistence.Transient">@Target({METHOD,FIELD})@Retention(RUNTIME)public @interface Transient {}</def></s3><s3 title="@Version"><p><code>@Version</code> marks a version field, used foroptimistic locking.</p><def title="javax.persistence.Version">@Target({METHOD,FIELD})@Retention(RUNTIME)public @interface Version {}</def></s3></s2><s2 title="Relation annotations"><s3 title="@JoinColumn"><p>Defines a join (foreign) columns. Used for <a href="#@ManyToOne">@ManyToOne</a>.</p><p>See also <a href="#@Column">@Column</a> forcorresponding definition for <a href="#@Basic">@Basic</a> columns.</p><p>See the <a href="../examples/amber-many2one/index.xtp">Many-to-Onetutorial</a> for a full example.</p><deftable><tr> <th>Property</th> <th>Description</th> <th>Default</th></tr><tr> <td>name</td> <td>The column name of the source table</td><td>the column name of the target key</td></tr><tr> <td>referencedColumnName</td> <td>The target column for composite keys</td><td>the single primary key</td></tr><tr> <td>unique</td> <td>True if unique</td> <td>false</td></tr><tr> <td>nullable</td> <td>False if IS NOT NULL</td> <td>true</td></tr><tr> <td>insertable</td> <td>True if the column is inserted on a <code>create</code></td> <td>true</td></tr><tr> <td>updateable</td> <td>True if the column is updated on field changes</td> <td>true</td></tr><tr> <td>columnDefinition</td> <td>SQL column definition</td> <td>false</td></tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -