I've just committed changes: added property "autoGenerated" to data source field.
Now your primary key should look like this:
Code:
<field name="id" type="text" autoGenerated="true" primaryKey="true" />
Regards,
Alius
<field name="id" type="text" autoGenerated="true" primaryKey="true" />
<field name="id" type="text" hidden="true" primaryKey="true" />
validate.primaryKeys.for.add: false
<id name="id" type="string"> <generator class="uuid"/> </id>
<field name="id" type="sequence" hidden="true" primaryKey="true" />
private String id;
@Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid2") @Column(updatable = false, length = 36) private String id;
=== 2012-09-20 12:16:21,279 [80-6] INFO RequestContext - URL: '/test/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header === 2012-09-20 12:16:21,280 [80-6] DEBUG IDACall - Header Name:Value pair: host:127.0.0.1:8080 === 2012-09-20 12:16:21,280 [80-6] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 === 2012-09-20 12:16:21,280 [80-6] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 === 2012-09-20 12:16:21,284 [80-6] DEBUG IDACall - Header Name:Value pair: accept-language:de,de-de;q=0.7,en;q=0.3 === 2012-09-20 12:16:21,284 [80-6] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate === 2012-09-20 12:16:21,284 [80-6] DEBUG IDACall - Header Name:Value pair: connection:keep-alive === 2012-09-20 12:16:21,284 [80-6] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8 === 2012-09-20 12:16:21,284 [80-6] DEBUG IDACall - Header Name:Value pair: referer:http://127.0.0.1:8080/index.html?gwt.codesvr=127.0.0.1:9997 === 2012-09-20 12:16:21,286 [80-6] DEBUG IDACall - Header Name:Value pair: content-length:1180 === 2012-09-20 12:16:21,286 [80-6] DEBUG IDACall - Header Name:Value pair: cookie:GLog=%7B%0D%20%20%20%20left%3A960%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A940%2C%20%0D%20%20%20%20height%3A919%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A4%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; JSESSIONID=2B62F007F075DD882A1FB8D4ABACA83F; isc_cState=ready === 2012-09-20 12:16:21,288 [80-6] DEBUG IDACall - Header Name:Value pair: pragma:no-cache === 2012-09-20 12:16:21,288 [80-6] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache === 2012-09-20 12:16:21,288 [80-6] DEBUG IDACall - session exists: 2B62F007F075DD882A1FB8D4ABACA83F === 2012-09-20 12:16:21,288 [80-6] DEBUG IDACall - remote user: null === 2012-09-20 12:16:21,291 [80-6] DEBUG XML - Parsed XML from (in memory stream): 2ms === 2012-09-20 12:16:21,293 [80-6] DEBUG RPCManager - Processing 1 requests. === 2012-09-20 12:16:21,295 [80-6] DEBUG RPCManager - Request #1 (DSRequest) payload: { criteria:{ id:"81d14483-5c31-4630-8213-f3464998c0a5" }, values:{ id:"81d14483-5c31-4630-8213-f3464998c0a5", definition:"123" }, operationConfig:{ dataSource:"attribute", operationType:"update" }, componentId:"isc_ListGrid_1", appID:"builtinApplication", operation:"attribute_update", oldValues:{ definition:"foo", id:"81d14483-5c31-4630-8213-f3464998c0a5", value:null } } === 2012-09-20 12:16:21,299 [80-6] INFO IDACall - Performing 1 operation(s) === 2012-09-20 12:16:21,299 [80-6] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2012-09-20 12:16:21,299 [80-6] DEBUG DeclarativeSecurity - DataSource attribute is not in the pre-checked list, processing... === 2012-09-20 12:16:21,299 [80-6] DEBUG AppBase - [builtinApplication.attribute_update] No userTypes defined, allowing anyone access to all operations for this application === 2012-09-20 12:16:21,299 [80-6] DEBUG AppBase - [builtinApplication.attribute_update] No public zero-argument method named '_attribute_update' found, performing generic datasource operation === 2012-09-20 12:16:21,300 [80-6] DEBUG ValidationContext - [builtinApplication.attribute_update] Adding validation errors at path '/attribute/id': {errorMessage=Must be a whole number.} === 2012-09-20 12:16:21,301 [80-6] INFO Validation - [builtinApplication.attribute_update] Validation error: [ { id:{ errorMessage:"Must be a whole number." } } ] === 2012-09-20 12:16:21,302 [80-6] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-09-20 12:16:21,305 [80-6] DEBUG RPCManager - non-DMI response, dropExtraFields: true === 2012-09-20 12:16:21,307 [80-6] INFO Compression - /test/sc/IDACall: 201 -> 173 bytes === 2012-09-20 12:16:21,879 [80-6] INFO RequestContext - URL: '/test/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header === 2012-09-20 12:16:21,880 [80-6] INFO Download - File C:/Projekte/test/smartgwtee-3.0p/samples/test/out/artifacts/test_war_exploded/test/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404 === 2012-09-20 12:16:22,019 [80-6] INFO RequestContext - URL: '/test/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header === 2012-09-20 12:16:22,020 [80-6] INFO Download - File C:/Projekte/test/smartgwtee-3.0p/samples/test/out/artifacts/test_war_exploded/test/sc/system/reference/skin/images/server_client_exchange.png not found, sending 404
<field name="id" type="text" primaryKey="true" />
@Entity @Table(name = "attribute") public class Attribute { @Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid2") @Column(updatable = false, length = 36) private Long id; private String value; @ManyToOne private AttributeDefinition definition; /* ... getter and setter ... */
@Entity @Table(name="attribute_definition") public class AttributeDefinition{ @Id private String name; private String type; /* ... getter and setter ... */
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DataSource ID="attribute" serverType="hibernate" dropExtraFields="true" beanClassName="test.Attribute"> <fields> <field name="id" type="text" primaryKey="true" /> <field name="value" type="text"/> <field name="definition" required="true" canEdit="true" foreignKey="attributeDefinition.name"/> </fields> </DataSource>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DataSource ID="attributeDefinition" serverType="hibernate" dropExtraFields="true" beanClassName="test.AttributeDefinition" > <fields> <field name="name" type="text" primaryKey="true"/> <field name="type" type="text" /> </fields> </DataSource>
public class Entry implements EntryPoint { public void onModuleLoad() { final ListGrid attributeDefinition = new ListGrid(); attributeDefinition.setDataSource(DataSource.get("attributeDefinition")); attributeDefinition.setCanDragRecordsOut(true); attributeDefinition.setDragDataAction(DragDataAction.COPY); attributeDefinition.setAlternateRecordStyles(true); attributeDefinition.setAutoFetchData(true); attributeDefinition.setFields( new ListGridField("name"), new ListGridField("type")); final ListGrid attribute = new ListGrid(); attribute.setDataSource(DataSource.get("attribute")); attribute.setCanAcceptDroppedRecords(true); attribute.setCanRemoveRecords(true); attribute.setAlternateRecordStyles(true); attribute.setAutoFetchData(true); attribute.setAutoFetchTextMatchStyle(TextMatchStyle.EXACT); ListGridField type = new ListGridField("type"); type.setIncludeFrom("attributeDefinition.type"); attribute.setFields( new ListGridField("id"), new ListGridField("value"), new ListGridField("definition"), type); HLayout mainLayout = new HLayout(); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.addMember(attributeDefinition); mainLayout.addMember(attribute); mainLayout.draw(); }
=== 2012-09-20 01:25:44,425 [80-2] INFO RequestContext - URL: '/test/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2': Moz (Gecko) with Accept-Encoding header === 2012-09-20 01:25:44,425 [80-2] DEBUG IDACall - Header Name:Value pair: host:127.0.0.1:8080 === 2012-09-20 01:25:44,425 [80-2] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 === 2012-09-20 01:25:44,425 [80-2] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 === 2012-09-20 01:25:44,430 [80-2] DEBUG IDACall - Header Name:Value pair: accept-language:de,de-de;q=0.7,en;q=0.3 === 2012-09-20 01:25:44,430 [80-2] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate === 2012-09-20 01:25:44,430 [80-2] DEBUG IDACall - Header Name:Value pair: connection:keep-alive === 2012-09-20 01:25:44,430 [80-2] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8 === 2012-09-20 01:25:44,430 [80-2] DEBUG IDACall - Header Name:Value pair: referer:http://127.0.0.1:8080/index.html?gwt.codesvr=127.0.0.1:9997 === 2012-09-20 01:25:44,432 [80-2] DEBUG IDACall - Header Name:Value pair: content-length:1011 === 2012-09-20 01:25:44,432 [80-2] DEBUG IDACall - Header Name:Value pair: cookie:GLog=%7B%0D%20%20%20%20left%3A960%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A942%2C%20%0D%20%20%20%20height%3A921%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A4%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready; JSESSIONID=17DD9EE8C70B93FF7E46B5B0ADDA6267 === 2012-09-20 01:25:44,434 [80-2] DEBUG IDACall - Header Name:Value pair: pragma:no-cache === 2012-09-20 01:25:44,434 [80-2] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache === 2012-09-20 01:25:44,434 [80-2] DEBUG IDACall - session exists: 17DD9EE8C70B93FF7E46B5B0ADDA6267 === 2012-09-20 01:25:44,434 [80-2] DEBUG IDACall - remote user: null === 2012-09-20 01:25:44,437 [80-2] DEBUG XML - Parsed XML from (in memory stream): 2ms === 2012-09-20 01:25:44,440 [80-2] DEBUG RPCManager - Processing 1 requests. === 2012-09-20 01:25:44,442 [80-2] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ name:"foo", type:"text", definition:"foo" }, operationConfig:{ dataSource:"attribute", operationType:"add" }, componentId:"isc_ListGrid_1", appID:"builtinApplication", operation:"attribute_add", oldValues:{ name:"foo", type:"text", definition:"foo" }, criteria:{ } } === 2012-09-20 01:25:44,446 [80-2] INFO IDACall - Performing 1 operation(s) === 2012-09-20 01:25:44,446 [80-2] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2012-09-20 01:25:44,446 [80-2] DEBUG DeclarativeSecurity - DataSource attribute is not in the pre-checked list, processing... === 2012-09-20 01:25:44,446 [80-2] DEBUG AppBase - [builtinApplication.attribute_add] No userTypes defined, allowing anyone access to all operations for this application === 2012-09-20 01:25:44,446 [80-2] DEBUG AppBase - [builtinApplication.attribute_add] No public zero-argument method named '_attribute_add' found, performing generic datasource operation === 2012-09-20 01:25:44,448 [80-2] INFO HibernateDataSource - [builtinApplication.attribute_add] Performing add operation with criteria: {name:"foo",type:"text",definition:"foo"} values: {name:"foo",type:"text",definition:"foo"} === 2012-09-20 01:25:44,449 [80-2] WARN RequestContext - dsRequest.execute() failed: com.isomorphic.base.UpdateWithoutPKException: Criteria received from the client for add operation is missing the following non-sequence primary key fields: [id]. Either provide all primary key fields that are not sequences, or set allowMultiUpdate on the OperationBinding at com.isomorphic.hibernate.HibernateDataSource.processRequest(HibernateDataSource.java:804) at com.isomorphic.hibernate.HibernateDataSource.executeAdd(HibernateDataSource.java:724) at com.isomorphic.datasource.DataSource.execute(DataSource.java:1359) at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726) at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658) at com.isomorphic.application.AppBase.execute(AppBase.java:491) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2000) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:216) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:173) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:138) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:74) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584) at java.lang.Thread.run(Thread.java:662) === 2012-09-20 01:25:44,450 [80-2] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-09-20 01:25:44,452 [80-2] DEBUG RPCManager - non-DMI response, dropExtraFields: true === 2012-09-20 01:25:44,453 [80-2] INFO Compression - /test/sc/IDACall: 346 -> 247 bytes
@Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid2") @Column(updatable = false, length = 36) private String uuid;
<field name="uuid" type="sequence" hidden="true" primaryKey="true" />
INFO Validation - [builtinApplication.evoProductAttribute_update] Validation error: [ { uuid:{ errorMessage:"Must be a whole number." } } ]
<field name="uuid" type="text" hidden="true" primaryKey="true" />
com.isomorphic.base.UpdateWithoutPKException: Criteria received from the client for add operation is missing the following non-sequence primary key fields: [uuid]. Either provide all primary key fields that are not sequences, or set allowMultiUpdate on the OperationBinding
Leave a comment: