Instalasi PATH JAVA di Windows

Instalasi PATH JAVA di Windows

computer ->control panel -> advanced system setting -> advenced -> PILIH Environments variable

variable name: CLASSPATH

variable value: C:\Program Files\Java\jdk1.8.0_60\lib\tools.jar;,

variable name: HOME

variable value: C:\Program Files\Java\jdk1.8.0_60;,

variable name: PATH

variable value: C:\Program Files\Java\jdk1.8.0_60\bin;,

PATH java

 

Advertisements

csv issue

manipulates content field from db into csv file format
this is a case from enum and then showing the char in csv
example 1

List<Object[]> results = query.getResultList();

        for (Object[] item : results) {
           i=0;




            for (Object object : item) {

                //change a status to 'char'
                if(i==2){
                    if (object.equals(0)){
                        csvResult.append("Junior High Student").append(',');
                    } else if(object.equals(1)){
                        csvResult.append("Senior High Student").append(',');
                    } else if(object.equals(2)){
                        csvResult.append("Diplouma Student").append(',');
                    } else if(object.equals(3)){
                        csvResult.append("Bachelor Student").append(',');
                    } else if(object.equals(4)){
                        csvResult.append("MSc Student").append(',');
                    } else if(object.equals(5)){
                        csvResult.append("Doctor Student").append(',');
                    } else {
                        csvResult.append(object).append(',');
                    }

                }
                else {
                    csvResult.append(object).append(',');
                     }
                i++;

             }
            csvResult.deleteCharAt(csvResult.length() - 1);
            csvResult.append('\n');
        }

changes value ‘null’ to string
example 2

       if(i==4){
                    if(object== null){
                        csvResult.append("Zero").append(',');
                    } else if(object != null) {
                        csvResult.append(object).append(',');
                    } else {
                        csvResult.append(object).append(',');
                    }
                }

JEE-persistence API (JPA)

JEE/ Java enterprise edition

JPA Java persistence

@CollectionTable is used to mapping of collections of basic or embeddable types.@Entity is allows collections of simple objects to be easily defined.

The entity’s persistent state is defined by four field, the identity id defined by the field id and is annotated with @id. A composite primary key may also be defined where the primary key corresponds to ome or more fields of the entity class. 

the implements  Serializable interface, and that allows it to be passed by value through a remote interface.

The relationships between different entities are defined using @OneToOne, @OneToMany, @ManyToOne and @ManyToMany annotation on the corresponding field of the referencing entity.

Validating the Entities.

validation has some predefined constraints like @Min, @Max, @Pattern and @Size.

@Entity
public class Student implements serializable {

@Id
private int id;

@Size(max=30)
private String name;

@Size(min=3, max=10)
private String grade;

@Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\."
        +"[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"
        +"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",message="{invalid.email}")
protected String email;
}