Hi All,
I have had some issues trying to install registry into my (local) maven repository, and I thought I might share them with you to find out whether I've been doing something wrong.
- First, I had to change the pom file to point onto hibernate-registry.hcf.xml, as the hibernate.hcf.xml was not existing;
- I also had to change the DTD in that hibernate-registry.hcf.xml file, as I was getting the following error when running "mvn install":
"Don't use old DTDs, read the Hibernate 3.x Migration Guide!"
- Then, I was getting the following error when trying to install the registry jar:
13:10:41,949 INFO org.hibernate.cfg.Configuration - Reading mappings from resource: net/smartlab/web/registry/Entry.hbm.xml
13:10:42,076 ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(185) The content of element type "set" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not parse mapping document from resource net/smartlab/web/registry/Entry.hbm.xml
After a bit of investigation, it turned out that one of the "set" definitions in that file was empty. I had to tweak the Hibernate configuration (and in the process I got the opportunity to curse maven once again).
I'm attaching the changes I've carried out on the project to finally get it to install correctly (though not being familiar with it, I am not sure whether the Hibernate changes I've made suit the db schema). I'm also attaching smartweb-registry.jar.hcf "as is", because despite having set its Subversion mime type to text/xml (as shown in patch), it wouldn't give me a diff. I'd be interested to know whether you've ever had that problem (the fact that I can't diff that file).
Anyway, did I miss something in that module?
Regards,
Sébastien.
__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités
http://mail.yahoo.fr Yahoo! Mail
Index: src/net/smartlab/web/registry/Entity.java
===================================================================
--- src/net/smartlab/web/registry/Entity.java (révision 1234)
+++ src/net/smartlab/web/registry/Entity.java (copie de travail)
@@ -208,8 +208,8 @@
* @return returns the relationships.
* @hibernate.set lazy="true" schema="registry" table="`relationship`"
* cascade="all"
- * @hibernate.key column="`source`"
- * @hibernate.composite-element class="net.smartlab.web.registry.Relationship"
+ * @hibernate.collection-key column="`source`"
+ * @hibernate.collection-one-to-many class="net.smartlab.web.registry.Relationship"
* @uml.property name="relationships"
*/
public Set getRelationships() {
@@ -276,7 +276,7 @@
Iterator relationships = this.relationships.iterator();
while (relationships.hasNext()) {
Relationship relationship = (Relationship)relationships.next();
- if (entity.equals(relationship.getTarget())) {
+ if (entity.equals(relationship.getRelationshipPk().getTarget())) {
relationships.remove();
}
}
Index: src/net/smartlab/web/registry/RelationshipPK.java
===================================================================
--- src/net/smartlab/web/registry/RelationshipPK.java (révision 0)
+++ src/net/smartlab/web/registry/RelationshipPK.java (révision 0)
@@ -0,0 +1,94 @@
+package net.smartlab.web.registry;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+public class RelationshipPK implements Serializable {
+
+ /**
+ * @TODO documentation
+ */
+ private static final long serialVersionUID = 1L;
+ /**
+ * The relationship source
+ * @uml.property name="source"
+ * @uml.associationEnd inverse="relationships:net.smartlab.web.registry.Entity"
+ * @directed true
+ */
+ private Entity source;
+ /**
+ * The relationship target.
+ * @directed true
+ */
+ private Entity target;
+
+
+
+ public RelationshipPK() {
+ super();
+ }
+ public RelationshipPK(Entity source, Entity target) {
+ super();
+ this.source = source;
+ this.target = target;
+ }
+ /**
+ * Returns the item from which the relationship originates.
+ *
+ * @return returns the source.
+ * @uml.property name="source"
+ * @hibernate.property column="`source`"
+ */
+ public Entity getSource() {
+ return source;
+ }
+ /**
+ * Returns the item to which the relationship is directed.
+ *
+ * @return returns the target.
+ * @hibernate.property column="`target`" not-null="true"
+ */
+ public Entity getTarget() {
+ return target;
+ }
+ /**
+ * Sets the item from which the relationship originates.
+ *
+ * @param source the source to set.
+ * @uml.property name="source"
+ */
+ public void setSource(Entity source) {
+ this.source = source;
+ }
+ /**
+ * Sets the item to which the relationship is directed.
+ *
+ * @param target the target to set.
+ */
+ public void setTarget(Entity target) {
+ this.target = target;
+ }
+
+
+ protected void reverse() {
+ Entity temp = this.target;
+ this.target = this.source;
+ this.source = temp;
+ }
+
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (!(o instanceof RelationshipPK)) return false;
+
+ RelationshipPK rPk = (RelationshipPK)o;
+
+ return new EqualsBuilder().append(getSource(), rPk.getSource())
+ .append(getTarget(), rPk.getTarget()).isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder(123455667, -1456658990).append(this.target).append(this.source).toHashCode();
+ }
+}
Index: src/net/smartlab/web/registry/Relationship.java
===================================================================
--- src/net/smartlab/web/registry/Relationship.java (révision 1234)
+++ src/net/smartlab/web/registry/Relationship.java (copie de travail)
@@ -22,6 +22,9 @@
*/
package net.smartlab.web.registry;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
import net.smartlab.web.BusinessObject;
/**
@@ -35,28 +38,16 @@
* should be created to ensure full browseability.
*
* @author rlogiacco
+ * @hibernate.class schema="registry" table="`relationship`"
* @stereotype component
*/
public class Relationship extends BusinessObject {
private static final long serialVersionUID = -6755482377883259670L;
+ private RelationshipPK relationshipPk = null;
+
/**
- * The relationship source
- * @uml.property name="source"
- * @uml.associationEnd inverse="relationships:net.smartlab.web.registry.Entity"
- * @directed true
- */
- private Entity source;
-
- /**
- * The relationship target.
- *
- * @directed true
- */
- private Entity target;
-
- /**
* A name identifying the relationship.
*/
private String name;
@@ -76,33 +67,11 @@
* @param name the relationship type.
*/
public Relationship(Entity source, Entity target, String name) {
- this.source = source;
- this.target = target;
+ this.relationshipPk = new RelationshipPK(source, target);
this.name = name;
}
/**
- * Returns the item from which the relationship originates.
- *
- * @return returns the source.
- * @uml.property name="source"
- * @hibernate.parent column="`source`"
- */
- public Entity getSource() {
- return source;
- }
-
- /**
- * Sets the item from which the relationship originates.
- *
- * @param source the source to set.
- * @uml.property name="source"
- */
- public void setSource(Entity source) {
- this.source = source;
- }
-
- /**
* Returns the relationship name.
*
* @return returns the name.
@@ -122,48 +91,38 @@
}
/**
- * Returns the item to which the relationship is directed.
- *
- * @return returns the target.
- * @hibernate.many-to-one column="`target`" not-null="true"
+ * Reverses the relationship direction.
*/
- public Entity getTarget() {
- return target;
+ public void reverse() {
+ this.relationshipPk.reverse();
}
+
+
/**
- * Sets the item to which the relationship is directed.
- *
- * @param target the target to set.
+ * @hibernate.id
+ * @TODO documentation
+ * @return
*/
- public void setTarget(Entity target) {
- this.target = target;
+ public RelationshipPK getRelationshipPk() {
+ return relationshipPk;
}
- /**
- * Reverses the relationship direction.
- */
- public void reverse() {
- Entity temp = this.target;
- this.target = this.source;
- this.source = temp;
+ public void setRelationshipPk(RelationshipPK relationshipPk) {
+ this.relationshipPk = relationshipPk;
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj instanceof Relationship) {
- Relationship relationship = (Relationship)obj;
- return relationship.target.getId() == this.target.getId() && relationship.name.equals(this.name);
- }
- return false;
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (!(o instanceof Relationship)) return false;
+
+ Relationship r = (Relationship)o;
+
+ return new EqualsBuilder().append(getRelationshipPk(), r.getRelationshipPk())
+ .append(getName(), r.getName()).isEquals();
}
-
- /**
- * @see java.lang.Object#hashCode()
- */
+
public int hashCode() {
- return ( this.name + this.source.getId() + this.target.getId()).hashCode();
+ return new HashCodeBuilder(123455667, -1456658990).append(this.relationshipPk).append(this.name).toHashCode();
}
}
Index: /home/sebastien/workspace/smartweb/modules/registry/res/smartweb-registry.jar.hcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: /home/sebastien/workspace/smartweb/modules/registry/res/smartweb-registry.jar.hcf
___________________________________________________________________
Name: svn:mime-type
- application/octet-stream
+ text/xml
Index: pom.xml
===================================================================
--- pom.xml (révision 1234)
+++ pom.xml (copie de travail)
@@ -260,7 +260,7 @@
</component>
</components>
<componentProperties>
- <configurationfile>${basedir}/res/smartweb.jar.hcf</configurationfile>
+ <configurationfile>${basedir}/res/smartweb-registry.jar.hcf</configurationfile>
<outputfilename>schema.sql</outputfilename>
<export>false</export>
<drop>true</drop>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
smartweb-user mailing list
smartweb-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/smartweb-user