cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with objectrelated mapping

Former Member
0 Kudos

Hello,

based on the Employee example of the book JAVA Programming with SAP Netweaver I try to develop the referenceapplication with a little modified context.

I use a table for cars instead for employees and created the following source code. My Problem is that all annotation like @Entity, @Table or @ID are highlightes as - @Entity/@Table/@ID cannot be resolved to a type.

Is there a problem with the package? If I try to Add imports over the contextmenue nothing happens.

But I know I should normaly import the javax.persistence.* package.

Is it necessary to install the javax.persistece packages manualy?????

Code:

package com.sap.demo;

import java.io.Serializable;

@Entity

@Table(name="TMP_Cars")

@TableGenerator(name="idGenerator", table="TMP_ID_GEN",

pkColumnName="GEN_Key", valueColumnName="GEN_VALUE")

public class Cars implements Serializable {

@ID

@GeneratedValue (strategy=GenerationType.Table,

generator="idGenerator")

private static final long serialVersionUID = 111L;

@Column(name="ID")

private long carId;

@Column(name="Manufacturer")

private String manufacturer;

@Column (name="Model")

private String model;

@Version

private int version;

public Cars() {

// TODO Auto-generated constructor stub

}

public long getCarId() {

return carId;

}

public void setCarId(long carId) {

this.carId = carId;

}

public String getManufacturer() {

return manufacturer;

}

public void setManufacturer(String manufacturer) {

this.manufacturer = manufacturer;

}

public String getModel() {

return model;

}

public void setModel(String model) {

this.model = model;

}

public int getVersion() {

return version;

}

public void setVersion(int version) {

this.version = version;

}

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Marco,

If you are using the SAP NetWeaver Developer Studio, you simply right-click on the entity code and choose Source >> Organize Imports

Hope that helps!

Regards,

Yordan

Former Member
0 Kudos

No unfortunately not. If I click right click to organise my imports nothing happens. Could it be that I use a older jdk. I m using 15.1.13 Is the javax.persistence package only with the jdk higher Version 6 availiable?

Regards

Marco

Former Member
0 Kudos

Hi, Marco,

JPA is available since Java EE 5, so I think jdk 1.5.* is OK.

Unfortunately, I cannot guess what might be the real problem in this case.

Regards,

Yordan

Former Member
0 Kudos

Did you try importing them manually, i.e. "import javax.persistence.*;"

Cheers,

Felix

Former Member
0 Kudos

Yes I tried this but it cant find the javax.persistnece package.

Former Member
0 Kudos

Did you enable the JPA facet of your project?

~felix

Former Member
0 Kudos

Ähm no. How and where can I do this?

Answers (0)