KomachiSion commented on issue #2138: Could not commit JPA transaction when I use save to insert data to oracledatabase URL: https://github.com/apache/incubator-shardingsphere/issues/2138#issuecomment-478417006 @fdlzp I have solved the problem. Your problem is caused by 2 configuration. 1. Field case, in your entity, you set field name as upper case and also set sharding configuration. But the hibernate would change it to lower case like following: ``` Terminal{id='null', cardNo='111', name='xxx', dateTime=Fri Mar 29 16:21:58 CST 2019}---2 Hibernate: insert into terminal (card_no, date_time, name, id) values (?, ?, ?, ?) 2019-04-01 10:37:36.993 INFO 1459 --- [nio-8080-exec-2] Sharding-JDBC-SQL : Logic SQL: insert into terminal (card_no, date_time, name, id) values (?, ?, ?, ?) 2019-04-01 10:37:36.995 INFO 1459 --- [nio-8080-exec-2] Sharding-JDBC-SQL : SQLStatement: InsertStatement(columns=[Column(name=card_no, tableName=terminal), Column(name=date_time, tableName=terminal), Column(name=name, tableName=terminal), Column(name=id, tableName=terminal)], multipleConditions=[], columnsListLastPosition=50, generateKeyColumnIndex=-1, afterValuesPosition=59, valuesListLastPosition=70, generatedKey=null) 2019-04-01 10:37:36.996 INFO 1459 --- [nio-8080-exec-2] Sharding-JDBC-SQL : Actual SQL: yytest ::: insert into yytest.TERMINAL_3 (card_no, date_time, name, id) values (?, ?, ?, ?) ::: [111, 2019-03-29 16:21:58.0, xxx, 38a8312d-800a-4039-ad8a-474e3dac7952] ``` It will cause groovy can't find the object `CARD_NO` and invoke `mod()` method. this problem can be solved by change configuration like following: ``` sharding.jdbc.config.sharding.tables.TERMINAL.table-strategy.inline.sharding-column=card_no sharding.jdbc.config.sharding.tables.TERMINAL.table-strategy.inline.algorithm-expression=system.TERMINAL_${card_no % 12} ``` 2. the `UUID` length is 36, because of the char '-', but you `ID` field length is 32 ``` /** * ID */ @Id @GeneratedValue(generator = "idGenerator") // @GenericGenerator(name = "idGenerator", strategy = "uuid") @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") @Column(name = "ID", nullable = false, length = 32) private String id ; ``` It also cause insert exception.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
