From: <one...@us...> - 2002-11-10 15:19:52
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory usw-pr-cvs1:/tmp/cvs-serv12595 Modified Files: ClassMapping.java Log Message: Max Andersen's patch for one-to-one support in codegenerator Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassMapping.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ClassMapping.java 21 Oct 2002 03:45:04 -0000 1.12 --- ClassMapping.java 10 Nov 2002 15:19:48 -0000 1.13 *************** *** 13,16 **** --- 13,17 ---- import cirrus.hibernate.type.Type; + import org.apache.commons.lang.StringUtils; import org.jdom.Attribute; import org.jdom.Element; *************** *** 70,74 **** // ensure that the type is specified String type = property.getAttributeValue("type"); ! if ( type == null || type.trim().equals("") ) { System.out.println("property \"" + name + "\" in class " + getName() + " is missing a type attribute"); continue; --- 71,75 ---- // ensure that the type is specified String type = property.getAttributeValue("type"); ! if (StringUtils.isEmpty(type)) { System.out.println("property \"" + name + "\" in class " + getName() + " is missing a type attribute"); continue; *************** *** 99,102 **** --- 100,121 ---- } } + + List onetooneList = classElement.getChildren("one-to-one"); + for (Iterator onetoones = onetooneList.iterator(); onetoones.hasNext();) { + Element onetoone = (Element) onetoones.next(); + + String name = onetoone.getAttributeValue("name"); + + // ensure that the class is specified + String clazz = onetoone.getAttributeValue("class"); + if(StringUtils.isEmpty(clazz)) { + System.out.println("one-to-one \"" + name + "\" in class " + getName() + " is missing a class attribute"); + continue; + } + + fields.add(new Field(name, getFieldType(clazz), true)); + + } + // many to ones - TODO: consolidate with code above |