-
1. Re: Unidirectional OneToMany
bill.burke Mar 30, 2005 11:34 AM (in response to schoetz)Specify a @JoinColumn(s) and this should work. Preview 4 does not currently implement the default mapping for this unidirectional case.
-
2. Re: Unidirectional OneToMany
schoetz Mar 31, 2005 1:55 AM (in response to schoetz)I already tried this. I get this error message:
Error parsing XML: XML String(221) The content of element type "list" must match "(meta*,subselect?,cache?,synchronize*,key,index,(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".
The definition looks like this:
@OneToMany
@JoinColumn( name = "TEST")
schoetz -
3. Re: Unidirectional OneToMany
ceracm Apr 6, 2005 1:00 PM (in response to schoetz)"bill.burke@jboss.com" wrote:
Specify a @JoinColumn(s) and this should work. Preview 4 does not currently implement the default mapping for this unidirectional case.
I am using EJB 3.0 preview 4.
I want to map a undirectional 1-to-many relationship with a foreign key (in the child table).
I expected to implement this using:
class Parent {
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name="PARENT_ID",referencedColumnName="ID")
private Collection children
}
In the generated schema the child table has a FK.
However, the generated hibernate-mapping contains inverse="true".
The children are persisted but the foreign key is never set to the parent's pk.
Are my annotations incorrect or is this not supported? -
4. Re: Unidirectional OneToMany
bill.burke Apr 6, 2005 1:04 PM (in response to schoetz)referencedColumn is not supported yet. I don't think it will be supported in the next release either (scheduled for this week). Apologies...
-
5. Re: Unidirectional OneToMany
schoetz Apr 7, 2005 2:33 AM (in response to schoetz)I fixed my problem now. I used java.util.List instead of java.util.Collection. Now everything works perfect with unidirectional OneToMany-Associations.
schoetz -
6. Re: Unidirectional OneToMany
epbernard Apr 7, 2005 4:03 PM (in response to schoetz)"bill.burke@jboss.com" wrote:
referencedColumn is not supported yet. I don't think it will be supported in the next release either (scheduled for this week). Apologies...
It is supported Bill :-) -
7. Re: Unidirectional OneToMany
ceracm Apr 7, 2005 4:26 PM (in response to schoetz)"epbernard" wrote:
"bill.burke@jboss.com" wrote:
referencedColumn is not supported yet. I don't think it will be supported in the next release either (scheduled for this week). Apologies...
It is supported Bill :-)
Please elaborate.
Are you saying that it will be supported in preview 5? -
8. Re: Unidirectional OneToMany
vincent_os Apr 15, 2005 6:55 AM (in response to schoetz)Hello,
I am having difficulty with the unidirectional OneToMany relationship.
I have 2 perisitant objects UserDO and ReportDO. UserDO has a OneToMany relationship with ReportDO. Here is the declaration of the mapping in UserDO:
/**
* @return Returns the reports.
*/
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
public Collection getReports()
{
return this.reports;
}
I am using EJB3.0 preview 5.
I have the following errors:
When I persist the UserDO the entity the persistance operation works as expected, propogating the persistance operation to the collection of ReportDO entities (I verified that all the data including the join table is populated with appropriate values in the database)
However, when I try to retrieve the newly perisited UserDO I get back an empty collection of reportDO.
Is this a known bug? -
9. Re: Unidirectional OneToMany
vincent_os Apr 15, 2005 7:24 AM (in response to schoetz)Please disregard my previous posting. I discovered my mistake. The OneToMany relationship works as specified.
-
10. Re: Unidirectional OneToMany
epbernard Apr 15, 2005 8:27 AM (in response to schoetz)"ceracm" wrote:
"epbernard" wrote:
"bill.burke@jboss.com" wrote:
referencedColumn is not supported yet. I don't think it will be supported in the next release either (scheduled for this week). Apologies...
It is supported Bill :-)
Please elaborate.
Are you saying that it will be supported in preview 5?
Sorry I did read too quicky.
Your case (ie non inverse onetomany is now supported in preview 5).
referencedColumnName is supported if (and only if) it points to a pk column (basically the default value), sorry :-(