Exception Description: Missing mapping for field id

View: New views
3 Messages — Rating Filter:   Alert me  

Exception Description: Missing mapping for field id

by Mihael Schmidt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am new to EclipseLink and JPA and have a problem with a ManyToMany
relationship with my entities.

I'm getting the error: Exception Description: Missing mapping for field
[public.hr_bewerbungen.id].

Tables:

create table hr_ursachen
(
    id serial not null primary key,
    bezeichnung text not null
);

create table hr_bewerbungen
(
    id serial not null primary key,
    bewerberId integer not null,
    stelleId integer not null,
    vorstellungstermin date,
    ergebnis text,
    bemerkung text,
    erfassungsdatum date,
    version timestamp
);

create table hr_herkunft
(
  bewerbungId integer not null,
  ursacheId integer not null,
  primary key(bewerbungId, ursacheId)
);

A "Bewerbung" can have many "Ursache". An "Ursache" can be a part of
many "Bewerbung". This is saved in the table hr_herkunft.


Classes:

@Entity
@Table(name = "hr_bewerbungen", schema="public")
public class Bewerbung
implements Serializable
{
    @Id
    @SequenceGenerator(name="hr_bewerbungen_id_seq", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="hr_bewerbungen_id_seq")
    private Integer id;

    @ManyToMany
    @JoinTable
    (
         name="hr_herkunft",
         joinColumns=
              @JoinColumn(name="bewerbungId", referencedColumnName="id"),
         inverseJoinColumns=
              @JoinColumn(name="ursacheId", referencedColumnName="id")
    )
    private List<Ursache> ursachen = new ArrayList<Ursache>();

    ...
}

@Entity
@Table(name = "hr_ursachen", schema="public")
public class Ursache
implements Serializable
{
    @Id
    private Integer id;
   
    ...
}

I need the information which "Ursache" a "Bewerbung" has. The other way
round is not important.

Any idea what I am doing wrong?

Thanx in advance.

Mihael
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Exception Description: Missing mapping for field id

by christopher delahunt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

The column name defaults to "ID" not "id".  Change your
referencedColumnName="ID" or define the column name on the private
Integer id to be "id".

Best Regards,
Chris

Mihael Schmidt wrote:

> Hi,
>
> I am new to EclipseLink and JPA and have a problem with a ManyToMany
> relationship with my entities.
>
> I'm getting the error: Exception Description: Missing mapping for
> field [public.hr_bewerbungen.id].
>
> Tables:
>
> create table hr_ursachen
> (
>    id serial not null primary key,
>    bezeichnung text not null
> );
>
> create table hr_bewerbungen
> (
>    id serial not null primary key,
>    bewerberId integer not null,
>    stelleId integer not null,
>    vorstellungstermin date,
>    ergebnis text,
>    bemerkung text,
>    erfassungsdatum date,
>    version timestamp
> );
>
> create table hr_herkunft
> (
>  bewerbungId integer not null,
>  ursacheId integer not null,
>  primary key(bewerbungId, ursacheId)
> );
>
> A "Bewerbung" can have many "Ursache". An "Ursache" can be a part of
> many "Bewerbung". This is saved in the table hr_herkunft.
>
>
> Classes:
>
> @Entity
> @Table(name = "hr_bewerbungen", schema="public")
> public class Bewerbung
> implements Serializable
> {
>    @Id
>    @SequenceGenerator(name="hr_bewerbungen_id_seq", allocationSize=1)
>    @GeneratedValue(strategy=GenerationType.SEQUENCE,
> generator="hr_bewerbungen_id_seq")
>    private Integer id;
>
>    @ManyToMany
>    @JoinTable
>    (
>         name="hr_herkunft",
>         joinColumns=
>              @JoinColumn(name="bewerbungId", referencedColumnName="id"),
>         inverseJoinColumns=
>              @JoinColumn(name="ursacheId", referencedColumnName="id")
>    )
>    private List<Ursache> ursachen = new ArrayList<Ursache>();
>
>    ...
> }
>
> @Entity
> @Table(name = "hr_ursachen", schema="public")
> public class Ursache
> implements Serializable
> {
>    @Id
>    private Integer id;
>      ...
> }
>
> I need the information which "Ursache" a "Bewerbung" has. The other
> way round is not important.
>
> Any idea what I am doing wrong?
>
> Thanx in advance.
>
> Mihael
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@...
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Exception Description: Missing mapping for field id

by Mihael Schmidt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanx that was it. Added a @Column(name="id") to the Integer id.

Though what makes me wonder is that I hadn't any problems without the
extra column definition so far.

Best Regards

Mihael


christopher delahunt schrieb:

> Hello,
>
> The column name defaults to "ID" not "id".  Change your
> referencedColumnName="ID" or define the column name on the private
> Integer id to be "id".
>
> Best Regards,
> Chris
>
> Mihael Schmidt wrote:
>> Hi,
>>
>> I am new to EclipseLink and JPA and have a problem with a ManyToMany
>> relationship with my entities.
>>
>> I'm getting the error: Exception Description: Missing mapping for
>> field [public.hr_bewerbungen.id].
>>
>> Tables:
>>
>> create table hr_ursachen
>> (
>>    id serial not null primary key,
>>    bezeichnung text not null
>> );
>>
>> create table hr_bewerbungen
>> (
>>    id serial not null primary key,
>>    bewerberId integer not null,
>>    stelleId integer not null,
>>    vorstellungstermin date,
>>    ergebnis text,
>>    bemerkung text,
>>    erfassungsdatum date,
>>    version timestamp
>> );
>>
>> create table hr_herkunft
>> (
>>  bewerbungId integer not null,
>>  ursacheId integer not null,
>>  primary key(bewerbungId, ursacheId)
>> );
>>
>> A "Bewerbung" can have many "Ursache". An "Ursache" can be a part of
>> many "Bewerbung". This is saved in the table hr_herkunft.
>>
>>
>> Classes:
>>
>> @Entity
>> @Table(name = "hr_bewerbungen", schema="public")
>> public class Bewerbung
>> implements Serializable
>> {
>>    @Id
>>    @SequenceGenerator(name="hr_bewerbungen_id_seq", allocationSize=1)
>>    @GeneratedValue(strategy=GenerationType.SEQUENCE,
>> generator="hr_bewerbungen_id_seq")
>>    private Integer id;
>>
>>    @ManyToMany
>>    @JoinTable
>>    (
>>         name="hr_herkunft",
>>         joinColumns=
>>              @JoinColumn(name="bewerbungId", referencedColumnName="id"),
>>         inverseJoinColumns=
>>              @JoinColumn(name="ursacheId", referencedColumnName="id")
>>    )
>>    private List<Ursache> ursachen = new ArrayList<Ursache>();
>>
>>    ...
>> }
>>
>> @Entity
>> @Table(name = "hr_ursachen", schema="public")
>> public class Ursache
>> implements Serializable
>> {
>>    @Id
>>    private Integer id;
>>      ...
>> }
>>
>> I need the information which "Ursache" a "Bewerbung" has. The other
>> way round is not important.
>>
>> Any idea what I am doing wrong?
>>
>> Thanx in advance.
>>
>> Mihael
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@...
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@...
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users