1
Transaction tx = Ebean.beginTransaction();
try {
Transaction tx = Ebean.beginTransaction();
try {
String sqlString = "INSERT INTO customers VALUES (1001,'Nichols', 'Alexandra', '17 Maple Drive', "+ "'Nashua', 'NH','03062', SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE (-71.48923,42.72347,NULL), NULL, NULL))";
SqlUpdate query = Ebean.createSqlUpdate(sqlString);
query.execute();
String sqlQuery =
"SELECT @@IDENTITY AS 'Identity'";
SqlQuery query2 = Ebean.createSqlQuery(sqlQuery);
List<SqlRow> list = query2.findList();
System.out.println(list.get(0));
} finally {
tx.commit();
}
它给出错误
[PersistenceException: Query threw SQLException:ORA-00936: missing expression
Query was:
SELECT @@IDENTITY AS 'Identity'
]
我如何获得的最后一个ID插入行?
使用ORDER BY说明在选择查询 – XING
@XING返回最后插入的记录ID,将只如果主键是自动递增的整数,则工作。 –