I am using Appfuse to develop my application. I got an exception as below. I guess the hibernate mapping had a problem with special column name ADSL_DEVICE.VALIDATE (using notation) cause errors. Please help me to resolve this problem.
When execute the test case, i get the warn and error message
Hibernate: select NODE_ID_SEQ.nextval from dual
Hibernate: insert into NODE (AREA_ID, DESCRIPTION, FIRMWARE_VERSION, IS_ENABLE, IS_VISIBLE, MIB_VERSION, NAME, PARENT_ID, NODE_TYPE_ID, SERIAL_NUMBER, SHORT_NAME, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ADSL_DEVICE (ADSL_NAME, ADSL_SERIAL_NUMBER, CONNECTION_REQUEST, HARDWARE_VERSION, IP_ADDRESS, MANUFACTURER, OUI, PRODUCT_CLASS, PROVISIONING_CODE, SOFTWARE_VERSION, VALIDATE, NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
WARN - SqlExceptionHelper.logExceptions(143) | SQL Error: 1747, SQLState: 42000
ERROR - SqlExceptionHelper.logExceptions(144) | ORA-01747: invalid user.table.column, table.column, or column specificationTests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.289 sec <<< FAILURE! testAddAdslFirmware(org.appfuse.dao.AdslDeviceDaoTest) Time elapsed: 8.249 sec <<< ERROR! org.hibernate.exception.SQLGrammarException: ORA-01747: invalid user.table.column, table.column, or column specification
Then I define the column name by adding quotes: 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;
}
....
}
But i still get error, the Hibernate Query seem to be deadlock and do not response any messages when execute query. What the error is? How can i fix the bug?
Hibernate: select NODE_ID_SEQ.nextval from dual Hibernate: insert into NODE (AREA_ID, DESCRIPTION, FIRMWARE_VERSION, IS_ENABLE, IS_VISIBLE, MIB_VERSION, NAME, PARENT_ID, NODE_TYPE_ID, SERIAL_NUMBER, SHORT_NAME, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ADSL_DEVICE (ADSL_NAME, ADSL_SERIAL_NUMBER, CONNECTION_REQUEST, HARDWARE_VERSION, IP_ADDRESS, MANUFACTURER, OUI, PRODUCT_CLASS, PROVISIONING_CODE, SOFTWARE_VERSION, "VALIDATE", NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
This is my test case:
The AdslDeviceDao class extends GenericDao from Appfuse
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());
}
}
Thank you!