我使用 olingo+JPA 和 MYSQL Db 创建了一个 oData 生产者,并实现了北风。我有一个表northwind.inventory_transactions,它与northwind.inventory_transaction_types 有fk 关系,这被转换为JPA 中的对象关系。当我使用 odata 时,我得到以下响应:
GET 请求 http/localhost:8080/sample/galaxyService.svc/InventoryTransactions?$format=json&$top=1
{ d: { 结果: [ { __metadata: { id: "http/localhost:8080/sample/galaxyService.svc/InventoryTransactions(35)", uri: "http/localhost:8080/sample/galaxyService.svc/InventoryTransactions(35) )”,类型:“sample.InventoryTransaction”},评论:null,客户:4,Extra: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" } }, OrderDetails: { __deferred: { uri: "http/localhost:8080/sample/galaxyService.svc/InventoryTransactions(35)/OrderDetails" } }, ProductDetails: { __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,“额外”:空,“订单”:空,“PurchaseOrder”:空,“InventoryTransactionType”:1,“数量”:75,“交易创建日期”:“/日期(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)值(?、?、?、?、?、?、? , ?, ?, ?, ?, ?) bind => [12 个参数绑定] 查询:InsertObjectQuery(model.InventoryTransaction@63adef6d)
有人可以指导如何在我们有这样的关系的地方发帖吗?
谢谢,阿努巴夫。