package com.farata.dto2extjs.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Is used to assign <a href="http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.IdGenerator">id generator</a> * for the Ext JS model * <p>Developer will annotate an id property field like it is shown below. This make sense specifically in one scenario: * when the id is autoincremented by the database. Java code generated by CDBExt expects that client sends temporary * negative values: -1, -2, etc. instead of the real id values. Negative values' domain is used to resolve temporary link * between parent and child records: what comes as -1 in the primary key property of the parent model matches -1 in * foreign key property of all child records of this parent. The insert logic of the code generated by CDBExt takes care of the replacement of * temporary negative values with the real ones. * <pre> * package clear.dto; * import com.farata.dto2extjs.annotations.JSClass; * @JSClass public class UserDTO { @JSGeneratedId public Integer id; public Double salary; public Date dob; } * </pre> * </p> * <p> * The resulting model will look the following way: * <pre>// Generated by DTO2EXTJS ... Ext.define('MyApp.model.clear.generated._User', { extend: 'Ext.data.Model', idgen: 'negativesequential', requires: [ 'Clear.data.NegativeSequentialIdGenerator', 'Ext.data.Types', 'MyApp.model.clear.Ticket' ], fields: [ { name: 'id', type: Ext.data.Types.NUMBER, useNull: true }, { name: 'salary', type: Ext.data.Types.NUMBER, useNull: true }, { name: 'dob', type: Ext.data.Types.DATE, useNull: true } ] } *</pre> * </p> */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.FIELD}) public @interface JSGeneratedId { }