Hi Tom,
yes BO_ID is created in the historylogentity table, but no foreign key
reference in the database. So outside the application there is no logical
link between those tables.
Greets, Benjamin
Tom Ware wrote:
> Hi Benjamin,
>
> In your example:
>
> @ManyToOne(cascade=CascadeType.ALL)
> private BoEntity bo;
>
> I would expect the foreign key to be defaulted to BO_ID.
>
> What result are you seeing?
>
> -Tom
>
> Benjamin Graf wrote:
>
>> Hi Tom,
>>
>> I think both are necessary. I'm trying to create a relationship with two
>> entities and I thought that toplink will "translate" it to foreign key
>> reference as mentioned in the spec.
>>
>> Code example:
>>
>> @Entity
>> @NamedNativeQuery(name="activeBO", query="select * from boentity where
>> status=0", resultClass=BoEntity.class)
>> public class BoEntity implements java.io.Serializable {
>> @Id
>> @GeneratedValue(strategy = GenerationType.AUTO)
>> private Long id;
>> @OneToMany(cascade=CascadeType.ALL, mappedBy="bo")
>> private Collection<HistoryLogEntity> history; ...
>> }
>>
>> @Entity
>> public class HistoryLogEntity implements java.io.Serializable {
>> @Id
>> @GeneratedValue(strategy = GenerationType.AUTO)
>> @Column(name="HistoryLogID")
>> private Long id;
>> @ManyToOne(cascade=CascadeType.ALL) private BoEntity bo;
>> ...
>> }
>>
>> Tom Ware wrote:
>>
>>
>>> Hi Benjamin,
>>>
>>> It is not clear to me which of the following you are attempting.
>>>
>>> 1. To create a OneToMany (and its corresponding ManyToOne) relationship
>>>
>> between two entities.
>>
>>
>>> 2. To automatically create tables from entities and have the database
>>>
>> foreign key constraint automatically generated.
>>
>>
>>> Please provide a little more detail about what you are trying to do and
>>>
>> the code that you are using to set up your ManyToOne.
>>
>>
>>> -Tom
>>>
>>> Benjamin Graf wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> does anybody know how to create a foreign key reference with toplink? I
>>>> tried several times with @OneToMany(mappedBy...) @ManyToOne, but I
didn't
>>>> succeed in creating a reference in the database table. Is that a
>>>>
>> limitation
>>
>>
>>>> of toplink because there are no further information in the
>>>> ejb3.0-persisitence-spec pdf-file.
>>>>
>>>> Regards, Benjamin
>>>>
>>>>
>>>>
>>
>>
>>
>
>
--
Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%!
Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer