我正在使用 Appfuse 开发我的应用程序。我得到了一个例外,如下所示。我猜休眠映射有问题,特殊列名ADSL_DEVICE.VALIDATE(使用符号)会导致错误。请帮我解决这个问题。
执行测试用例时,我收到警告和错误消息
Hibernate:从双重
Hibernate 中选择 NODE_ID_SEQ.nextval:插入 NODE(AREA_ID,DESCRIPTION,FIRMWARE_VERSION,IS_ENABLE,IS_VISIBLE,MIB_VERSION,NAME,PARENT_ID,NODE_TYPE_ID,SERIAL_NUMBER,SHORT_NAME,ID)值(?,?,?,?,?, ?,?,?,?,?, ?
,? ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) WARN - SqlExceptionHelper.logExceptions(143) | SQL 错误:1747,SQLState:42000 错误 - SqlExceptionHelper.logExceptions(144) | ORA-01747: 无效的 user.table.column、table.column 或列规范测试运行:1,失败:0,错误:1,跳过:0,经过的时间:9.289 秒 <<< 失败!testAddAdslFirmware(org.appfuse.dao.AdslDeviceDaoTest) 经过时间:8.249 秒 <<< 错误!org.hibernate.exception.SQLGrammarException: ORA-01747: 无效的 user.table.column、table.column 或列规范
然后我通过添加引号来定义列名:ADSL_DEVICE."VALIDATE"
@Entity
@Table(name = AdslDevice.TABLE_NAME, uniqueConstraints =
@UniqueConstraint(columnNames = AdslDevice.SERIAL_NUMBER))
@PrimaryKeyJoinColumn(name = AdslDevice.NODE_ID)
public class AdslDevice
extends Node
implements java.io.Serializable {
// Constant
public static final String TABLE_NAME = "ADSL_DEVICE";
public static final String NODE_ID = "NODE_ID";
public static final String ADSL_NAME = "ADSL_NAME";
public static final String SERIAL_NUMBER = "ADSL_SERIAL_NUMBER";
....
@Column(name = "\"VALIDATE\"", length = 1)
public String getValidate() {
return this.validate;
}
public void setValidate(String validate) {
this.validate = validate;
}
....
}
但我仍然得到错误,休眠查询似乎是死锁并且在执行查询时不响应任何消息。错误是什么?我该如何修复错误?
Hibernate:从双重 Hibernate 中选择 NODE_ID_SEQ.nextval:插入 NODE(AREA_ID,DESCRIPTION,FIRMWARE_VERSION,IS_ENABLE,IS_VISIBLE,MIB_VERSION,NAME,PARENT_ID,NODE_TYPE_ID,SERIAL_NUMBER,SHORT_NAME,ID)值(?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?)
休眠:插入 ADSL_DEVICE (ADSL_NAME, ADSL_SERIAL_NUMBER, CONNECTION_REQUEST, HARDWARE_VERSION, IP_ADDRESS, MANUFACTURER, OUI, PRODUCT_CLASS, PROVISIONING_CODE, SOFTWARE_VERSION, "VALIDATE", NODE_ID) 值 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
这是我的测试用例:
AdslDeviceDao 类从 Appfuse 扩展了 GenericDao
public class AdslDeviceDaoTest extends BaseDaoTestCase {
@Autowired
private AdslDeviceDao adslDeviceDao;
@Test
public void testAddAdslFirmware() {
NodeType type = new NodeType();
type.setId(1L);
AdslDevice node = new AdslDevice();
// Node values
node.setArea(new Area(1L, "Ha noi"));
node.setDescription("Node desc");
node.setFirmwareVersion("1.0");
node.setIsEnable((short)1);
node.setIsVisible((short)1);
node.setMibVersion("v1");
node.setName("Node name");
node.setNodeType(type);
node.setSerialNumber("4578787864896");
node.setShortName("S1");
// adsl values
node.setAdslName("Adsl name");
node.setAdslSerialNumber("4578787864896");
node.setHardwareVersion("1.0");
node.setIpAddress("10.2.4.58");
node.setManufacturer("Vnpttech");
node.setOui("6.1.2.3");
node.setProductClass("Product class");
node.setProvisioningCode("6630");
node.setSoftwareVersion("11");
node.setValidate("1");
Node nodenew = adslDeviceDao.save(node);
flush();
assertEquals("F23", nodenew.getName());
assertNotNull(nodenew.getId());
}
}
谢谢!