[Hibernate-JIRA] Commented: (HBX-524) Reverse of one-to-one relationships
by Marcio Carvalho (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-524?page=co... ]
Marcio Carvalho commented on HBX-524:
-------------------------------------
Ok, Max, I am really sorry.
I forgot to mention that part of my change (item 1).
First of all, I apologyze to everybody that I could not find much time to build a patch of my solution. Also I didn't believe that my work could be useful for anybody else than my team, so I formatted the code in Eclipse making difficult to create a patch for my changes (it included all the classes code just because of changes in line positions).
Another one of my changes was the insertion of the code below at the end of the bindPrimaryKeyToProperties method (after the line containing "rc.setIdentifier(id);"):
ForeignKey oneToOneFk = findOneToOneOwnerFK(rc);
if (oneToOneFk != null) {
Property prop =
bindOneToOne(rc, oneToOneFk.getReferencedTable(),
oneToOneFk, processed);
rc.addProperty(prop);
}
And I had to create the findOneToOneOwnerFK method used above. Here it goes:
protected ForeignKey findOneToOneOwnerFK(RootClass rc) {
ForeignKey found = null;
boolean isOneToOne = false;
Iterator foreignKeys = rc.getTable().getForeignKeyIterator();
while (!isOneToOne && foreignKeys.hasNext()) {
ForeignKey fk = (ForeignKey) foreignKeys.next();
isOneToOne = isOneToOne(fk);
if (isOneToOne)
found = fk;
}
return found;
}
So, this change will create a OneToOne reference in the child pointing to the OneToOne owner.
It worked fine for me. Maybe the code I inserted at the end of the bindPrimaryKeyToProperties method could have been placed in a better point. Feel free to change.
There are some other helper methods that I created in the Cfg2HbmTool class to guide the pojo generation.
Let me just prepare my lunch and I create a patch to these remaining few changes, and my JPA annotated pojo template.
Regards,
Marcio.
> Reverse of one-to-one relationships
> -----------------------------------
>
> Key: HBX-524
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-524
> Project: Hibernate Tools
> Issue Type: Bug
> Components: reverse-engineer
> Affects Versions: 3.1beta2
> Environment: HIbernate 3.1, Oracle 9i
> Reporter: Andrea Cattani
> Assignee: Max Rydahl Andersen
> Attachments: patch.txt
>
>
> Hi,
> I've posted this issue to the forum and got this response from Max, Hibernate Team:
> "the reveng tools does not detect this as a one-to-one. it probably could, so add a request/patch to jira."
> The problem I've faced is the following:
> I have two tables, let's say
> - table A with column ID (PK) and other fields
> - table B with column ID (PK) and other fields
> table B has a foreign key constraint against table A, from column ID to column ID (one-to-one)
> When I reverese the tables with the HibernateTools I have such a resultant mapping for table B:
> <class name="B" table="B" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned" />
> </id>
> <[b]many-to-one name[/b]="a" class="A" update="false" insert="false" fetch="select">
> <column name="ID" length="12" not-null="true" unique="true" />
> </many-to-one>
> ....
> And this one for table A:
> <class name="A" table="A" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned"/>
> </id>
> <set name="b" inverse="true">
> <key>
> <column name="ID" length="12" not-null="true" unique="true" />
> </key>
> <[b]one-to-many[/b] class="B" />
> </set>
> </class>
> while I was expecting something like:
> [i]<one-to-one name="a" class="A" constrained="true"/>[/i]
> in table B, and the same (or nothing) in table A
> Thank you
> Andi
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[Hibernate-JIRA] Commented: (HBX-524) Reverse of one-to-one relationships
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-524?page=co... ]
Max Rydahl Andersen commented on HBX-524:
-----------------------------------------
Ok, i've been looking into this path and it *almost* works.
Here are the current issues I got with it (which i'm looking into fix or at least have good default handling for)
0) the current version only works for one-to-one on primary key; which is fine for now.
1) the "child" one-to-one side does not have the foreign-key generator set to foreign
2) the JPA generation is not there - Marcio, do you got those and might want to contribute ?
I'm interested in hearing how you with #1 could make it work ?
> Reverse of one-to-one relationships
> -----------------------------------
>
> Key: HBX-524
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-524
> Project: Hibernate Tools
> Issue Type: Bug
> Components: reverse-engineer
> Affects Versions: 3.1beta2
> Environment: HIbernate 3.1, Oracle 9i
> Reporter: Andrea Cattani
> Assignee: Max Rydahl Andersen
> Attachments: patch.txt
>
>
> Hi,
> I've posted this issue to the forum and got this response from Max, Hibernate Team:
> "the reveng tools does not detect this as a one-to-one. it probably could, so add a request/patch to jira."
> The problem I've faced is the following:
> I have two tables, let's say
> - table A with column ID (PK) and other fields
> - table B with column ID (PK) and other fields
> table B has a foreign key constraint against table A, from column ID to column ID (one-to-one)
> When I reverese the tables with the HibernateTools I have such a resultant mapping for table B:
> <class name="B" table="B" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned" />
> </id>
> <[b]many-to-one name[/b]="a" class="A" update="false" insert="false" fetch="select">
> <column name="ID" length="12" not-null="true" unique="true" />
> </many-to-one>
> ....
> And this one for table A:
> <class name="A" table="A" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned"/>
> </id>
> <set name="b" inverse="true">
> <key>
> <column name="ID" length="12" not-null="true" unique="true" />
> </key>
> <[b]one-to-many[/b] class="B" />
> </set>
> </class>
> while I was expecting something like:
> [i]<one-to-one name="a" class="A" constrained="true"/>[/i]
> in table B, and the same (or nothing) in table A
> Thank you
> Andi
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[Hibernate-JIRA] Assigned: (HBX-524) Reverse of one-to-one relationships
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-524?page=co... ]
Max Rydahl Andersen reassigned HBX-524:
---------------------------------------
Assignee: Max Rydahl Andersen
> Reverse of one-to-one relationships
> -----------------------------------
>
> Key: HBX-524
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-524
> Project: Hibernate Tools
> Issue Type: Bug
> Components: reverse-engineer
> Affects Versions: 3.1beta2
> Environment: HIbernate 3.1, Oracle 9i
> Reporter: Andrea Cattani
> Assignee: Max Rydahl Andersen
> Attachments: patch.txt
>
>
> Hi,
> I've posted this issue to the forum and got this response from Max, Hibernate Team:
> "the reveng tools does not detect this as a one-to-one. it probably could, so add a request/patch to jira."
> The problem I've faced is the following:
> I have two tables, let's say
> - table A with column ID (PK) and other fields
> - table B with column ID (PK) and other fields
> table B has a foreign key constraint against table A, from column ID to column ID (one-to-one)
> When I reverese the tables with the HibernateTools I have such a resultant mapping for table B:
> <class name="B" table="B" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned" />
> </id>
> <[b]many-to-one name[/b]="a" class="A" update="false" insert="false" fetch="select">
> <column name="ID" length="12" not-null="true" unique="true" />
> </many-to-one>
> ....
> And this one for table A:
> <class name="A" table="A" schema="SCHEMA">
> <id name="id" type="string">
> <column name="ID" length="12" />
> <generator class="assigned"/>
> </id>
> <set name="b" inverse="true">
> <key>
> <column name="ID" length="12" not-null="true" unique="true" />
> </key>
> <[b]one-to-many[/b] class="B" />
> </set>
> </class>
> while I was expecting something like:
> [i]<one-to-one name="a" class="A" constrained="true"/>[/i]
> in table B, and the same (or nothing) in table A
> Thank you
> Andi
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[Hibernate-JIRA] Created: (HHH-3411) Dead code in 3.3.0 CR1
by Emeric Vernat (JIRA)
Dead code in 3.3.0 CR1
----------------------
Key: HHH-3411
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3411
Project: Hibernate3
Issue Type: Improvement
Components: caching (L2), core
Affects Versions: 3.3.0.CR1
Environment: hibernate 3.3.0 CR1
Reporter: Emeric Vernat
Priority: Minor
I can be wrong but I found that the following package-private methods are dead code.
If they where supposed to be used there is a bug otherwise it could certainly be deleted.
They can't be used by applications as they are neither public nor protected (except by reflection which would be a hack).
getPreInval() in class org.hibernate.cache.jbc2.timestamp.ClusteredConcurrentTimestampsRegionImpl$Entry.
getLoadingCollectionXRefs() in class org.hibernate.engine.loading.LoadContexts.
afterDeserialize(...) in class org.hibernate.engine.EntityEntry, or is it called magically ?
getJoinType() in class org.hibernate.engine.JoinSequence$Join, but perhaps it should be called in JoinSequence#toJoinFragment.
getOwner() and getOwnerIdentifier() in class org.hibernate.event.def.ReattachVisitor.
process(...) in class org.hibernate.event.def.WrapVisitor.
constructor (String, List, Collection, FlushMode, boolean, SessionImplementor, ParameterMetadata) in class org.hibernate.impl.SQLQueryImpl.
For reference and future check these dead code methods were found with Dead Code Detector (http://dcd.dev.java.net)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months
[Hibernate-JIRA] Commented: (HV-21) Base class validations are not over-ridden
by Natalia K (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HV-21?page=com.... ]
Natalia K commented on HV-21:
-----------------------------
I have found the same bug and hope to it's fixing soon.
Emmanuel, I think - no overlapping should be done. Or at least there should be a way to override annotation completely. Because it should correspond to the meaning of overriding itself. If you override something - you try to change it. Not to save old behavior and add something new, but completely change. That's why you usually use overriding.
In our project we had been trying to use Hibernate Validator, but got stuck with this bug. If it is fixed in the future, we will be able to use HV.
For example, we have hierarchy, and in general we have property "age" within range(15,45). But for only one child we should change this range. And I want to have an opportunity to override that range.
If you can recommend something to override annotation in a different way, please, let me know that way.
Beforehand thank you for help.
> Base class validations are not over-ridden
> ------------------------------------------
>
> Key: HV-21
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-21
> Project: Hibernate Validator
> Issue Type: Improvement
> Components: engine
> Environment: hibernate 3.2 cr2
> Reporter: Aseel Abbas
>
> When the same validation annotation is applied to an over-riding method in a subclass the expected behaviour is that the validation annotation in the base class is over-ridden. Currently, both validations are executed. This severely limits the usability of the package for domain models where inheritance is used.
> The problem also occurs with over-riding interfaces.
> For example:
> class A {
> @Length (min = 0, max = 32)
> Integer getFoo() {
> return foo;
> }
> }
> class B extends A
> {
> @Length (min = 15, max = 20)
> Integer getFoo() {
> return super.getFoo();
> }
> }
> In this case validating an instance of class B which has a foo value of 100 will result in two error messages: "foo must be between 15 and 20" and "foo must be between 0 and 32".
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months