我使用olingo + JPA创建了一个oData生成器,其中MYSQL Db具有northwind实现。 我有一个表northwind.inventory_transactions与northwind.inventory_transaction_types有fk关系,这在JPA中被转换为对象关系。当我使用odata时,我得到以下回复:
获取请求 ?HTTP /本地主机:8080 /样品/ galaxyService.svc / InventoryTransactions $格式= JSON&安培; $顶部= 1
{d:{results:[{ __metadata:{id:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)”, URI: “HTTP /本地主机:8080 /样品/ galaxyService.svc / InventoryTransactions(35)”, 类型:“sample.InventoryTransaction”},评论:null,客户:4, 额外:null,Id:35,InventoryTransactionType:1,Order:null, PurchaseOrder:null,数量:75,TransactionCreatedDate: “/ Date(1143023548000)/”,TransactionModifiedDate: “/ Date(1143023548000)/”,重量:“0”,CustomerDetails:{ __deferred:{
enter code here
uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ CustomerDetails” ,InventoryTransactionTypeDetails:{ __deferred:{uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ InventoryTransactionTypeDetails” } }, 订单详细信息: { __deferred:{uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ OrderDetails” } }, 产品详情: { __deferred:{uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ ProductDetails” ,PurchaseOrderDetails:{ __deferred:{uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ PurchaseOrderDetails” ,PurchaseOrderDetailDetails:{ __deferred:{uri:“http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions(35)/ PurchaseOrderDetailDetails” }}}}}
在使用POSTMAN插件尝试POST操作时,我得到异常为“” 以下是要求 POST http / localhost:8080 / sample / galaxyService.svc / InventoryTransactions
{ “评论”: ””, “客户”:4, “额外”:null, “订单”:null, “PurchaseOrder”:null, “InventoryTransactionType”:1, “数量”:75, “TransactionCreatedDate”:“/ Date(1143023548000)/”, “TransactionModifiedDate”:“/日期(1143023548000)/”, “重量”:“0”
} 错误:
异常[EclipseLink-4002](Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException 内部 例外: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: 列'transaction_type'不能为null 错误代码:1048 致电:INSERT INTO inventory_transactions(ID,COMMENTS,EXTRA, QUANTITY,transaction_created_date,transaction_modified_date,WEIGHT, CustomerCode,transaction_type,customer_order_id,PRODUCT_ID, purchase_order_id)VALUES(?,?,?,?,?,?,?,?,?,?,?,?) bind => [12个参数绑定] 查询: InsertObjectQuery(model.InventoryTransaction@63adef6d)
有人可以指导如何发布我们有这样关系的帖子吗?
谢谢, Anubhav。