Sun Application Server Startup Command: /opt/SUNWappserver/bin/asadmin start-domain --domaindir /opt/SUNWappserver/domains --user admin

Friday, June 09, 2006

Hibernate: Get Length and Type attribute from property on mapping file using JAVA

After get configuration, you can get length from property.

public Configuration getConfiguration() {
Configuration configuration = new Configuration();
setMappings(configuration);

Iterator classMappings = configuration.getClassMappings();
while (classMappings.hasNext()) {
PersistentClass cm = (PersistentClass) classMappings.next();
Iterator propertyIterator = cm.getPropertyIterator();
while (propertyIterator.hasNext()) {
Property element = (Property) propertyIterator.next();
//Logger.debug(cm.getEntityName() + " = " + element.getName());
Iterator columnIterator = element.getValue().getColumnIterator();
while (columnIterator.hasNext()) {
Column col = (Column) columnIterator.next();
//Logger.debug(col.getName() + " > " + col.getLength());
}
}
}
return configuration;
}

private void setMappings(Configuration configuration) {
String[] files = new String[] { "AvailabilityCode", "StateCode",
"StatusCode", "SuitabilityCode", "ReasonCode", "Property",
"PropertyHistory", "Publication", "Agency", "PasswordHistory",
"UnsuitableReason", "User", "PropertyNumberSequence",
"FieldOfficeCode", "FieldOfficePoc", "DodDepartment",
"BracApplication", "Contact", "ContactType" };
for (int i = 0; i <>

No comments: