четверг, 25 августа 2016 г.

Make JPA Entity with @OneToMany and @ManyToOne mapping tags

Problem:
Your need to make JPA Entity with @OneToMany and @ManyToOne mapping tags.

Solution:
You have tables like this:

Table "Requests":
Field Type
ID Integer
STEP_ID Integer

Table "Steps":
Field Type
ID Integer
REQUEST_ID Integer

Table "Requests" should have in field "Step_Id" many rows from table "Steps", and table "Steps" should have in field "Requst_Id" one row from "Requests" table.

Make JPA Entities like this:

@Entity
@Table(name="REQUESTS")
public class Requests implements Serializable {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;

@OneToMany(mappedBy="request", fetch=FetchType.EAGER)
private Set<Steps> steps = new HashSet<Steps>();


public Requests() {
}

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public void setSteps(Set<Steps> history) {
this.steps = steps ;
}

public Set<Steps> getSteps() {
return steps;
}
}

@Entity
@Table(name="STEPS")
public class Steps implements Serializable {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;

@ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch=FetchType.EAGER)
@JoinColumn(name = "REQUEST_ID")
private EoRequestsEntity request;

public Steps() {
}

public int getId() {
return this.id;
}

public void setRequest(Requests request) {
this.request = request;
}

public EoRequestsEntity getRequest() {
return request;
}

}


Tags "cascade" and "fetch" is required!

That's all!

среда, 24 августа 2016 г.

How to create iView for sap portal web module application

Problem:
How to create iView for sap portal web module application

Solution:

  1. Create URL iView and set link to your web module application. If you do not know thar, you can run it in your Netweaver Developer Studio: right hand mouse click on development component, choose Run on Server - choose your server and run it. You will see url in browser.
  2. In iView properties set property Fetch Mode - Server Side.



пятница, 12 августа 2016 г.

Check if your TLD is valid against its scheme

Problem:
You have an error:
Caused by: com.sap.engine.services.servlets_jsp.jspparser_api.exception.JspParseException: Error in parsing the taglib tag in the JSP page. Cannot resolve URI: [http://java.s.com/jsf/html]. Possible reason - validation failed. Check if your TLD is valid against its scheme. 


Solution:
Put in your ear (Enterprise Application) development component in file ""META-INF/application-j2ee-engine.xml"" that code:

 <application-j2ee-engine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd"> 
    <reference reference-type="weak">
    <reference-target target-type="library" provider-name="sap.com">
       tc~ui~faces
    </reference-target>
    </reference>
  </application-j2ee-engine>

End everything works!