Skip to main content

Create Empty tag in Jaxb2


jaxb.properties
javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory



package com.infodart.central.integration.demo.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.eclipse.persistence.oxm.annotations.XmlMarshalNullRepresentation;
import org.eclipse.persistence.oxm.annotations.XmlNullPolicy;
import com.infodart.central.integration.demo.util.Constants;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "WHDEO")
@XmlType(propOrder = { "state", "currencyCode", "email", "country", "orgUnitId", "warehouseId", "warehouseName", "address1", "address2", "city", "pincode", "phoneNumber"})
@Entity
@Table(name = Constants.TABLE_EBS_WAREHOUSE)
public class EbsWarehouse implements java.io.Serializable {
private static final long serialVersionUID = -7520690623726202333L;
@XmlTransient
@Id
@Column(name = "ID")
private String id;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "Wh")
@Column(name = "WAREHOUSE_ID")
private String warehouseId;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "OrgUnitId")
@Column(name = "ORG_UNIT_ID")
private String orgUnitId;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "WhName")
@Column(name = "WAREHOUSE_NAME")
private String warehouseName;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "CurrencyCode")
@Column(name = "CURRENCY_CODE")
private String currencyCode;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "CountryId")
@Column(name = "COUNTRY")
private String country;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "State")
@Column(name = "STATE")
private String state;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "WhCity", required=true, nillable = true)
@Column(name = "CITY")
private String city;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "WhAdd1")
@Column(name = "ADDRESS1")
private String address1;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "WhAdd2")
@Column(name = "ADDRESS2")
private String address2;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "WhPcode")
@Column(name = "PINCODE")
private String pincode;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name = "PhoneNum")
@Column(name = "PHONE_NUMBER")
private String phoneNumber;
@XmlNullPolicy(emptyNodeRepresentsNull=true, nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE)
@XmlElement(name="Email")
@Column(name = "EMAIL")
private String email;
@XmlTransient
@Column(name = "MESSAGE_TYPE")
private String messageType;
@XmlTransient
@Column(name = "STATUS")
private String status;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getWarehouseId() {
return warehouseId;
}
public void setWarehouseId(String warehouseId) {
this.warehouseId = warehouseId;
}
public String getOrgUnitId() {
return orgUnitId;
}
public void setOrgUnitId(String orgUnitId) {
this.orgUnitId = orgUnitId;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public String getCurrencyCode() {
return currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getPincode() {
return pincode;
}
public void setPincode(String pincode) {
this.pincode = pincode;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getMessageType() {
return messageType;
}
public void setMessageType(String messageType) {
this.messageType = messageType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public EbsWarehouse() {
}
public EbsWarehouse(String id, String warehouseId, String orgUnitId, String warehouseName, String currencyCode, String country, String state, String city, String address1, String address2,
String pincode, String phoneNumber, String email, String messageType, String status) {
super();
this.id = id;
this.warehouseId = warehouseId;
this.orgUnitId = orgUnitId;
this.warehouseName = warehouseName;
this.currencyCode = currencyCode;
this.country = country;
this.state = state;
this.city = city;
this.address1 = address1;
this.address2 = address2;
this.pincode = pincode;
this.phoneNumber = phoneNumber;
this.email = email;
this.messageType = messageType;
this.status = status;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("EbsWarehouse [");
if (id != null)
builder.append("id=").append(id).append(", ");
if (warehouseId != null)
builder.append("warehouseId=").append(warehouseId).append(", ");
if (orgUnitId != null)
builder.append("orgUnitId=").append(orgUnitId).append(", ");
if (warehouseName != null)
builder.append("warehouseName=").append(warehouseName).append(", ");
if (currencyCode != null)
builder.append("currencyCode=").append(currencyCode).append(", ");
if (country != null)
builder.append("country=").append(country).append(", ");
if (state != null)
builder.append("state=").append(state).append(", ");
if (city != null)
builder.append("city=").append(city).append(", ");
if (address1 != null)
builder.append("address1=").append(address1).append(", ");
if (address2 != null)
builder.append("address2=").append(address2).append(", ");
if (pincode != null)
builder.append("pincode=").append(pincode).append(", ");
if (phoneNumber != null)
builder.append("phoneNumber=").append(phoneNumber).append(", ");
if (email != null)
builder.append("email=").append(email).append(", ");
if (messageType != null)
builder.append("messageType=").append(messageType).append(", ");
if (status != null)
builder.append("status=").append(status);
builder.append("]");
return builder.toString();
}
}

Comments

Popular posts from this blog

Conversion from Clob To String in java and Vice versa

/***reading Clob data from oracle table and setting to Pojo**/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import oracle.sql.CLOB;

import com.poc.one.pojo.StagedMessage;

public class MessageDao {
private static String url = "jdbc:oracle:thin:@172.22.22.198:1521:ORACLE";
private static String username = "ABC123";
private static String password = "ABC123";


public  List readClobToBO() throws Exception {

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, username, password);
PreparedStatement stmt = conn
.prepareStatement("SELECT ID, STORE_ID, MESSAGE_DATA FROM STAGED_MESSAGE ");
ResultSet resultSet = stmt.executeQuery();
List msgList= new ArrayList();

while (resultSet.next()) {

StagedMessage message = new StagedMessage();

message.setId(resultSet.getInt(1));
message.setStoreId(r…

Portable Java 8/ JDK8 setup without admin rights

Some time we got machine to work where we don't have access rights to install anything or if you do not want to install. You can get latest jdk running by this trick. Just follow step step & do comment if you like it.

Step by Step details to get running java from .exe setup without any admin rights. Get portable 7 zip from portableapps.comdownload java 8 from oracle  http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlopen 7 zip & extract jdk-8u102-windows-x64.exeyou will see below folders                .data                .pdata                .rdata                .reloc                .rsrc                .text                CERTIFICATE

          5.Go inside E:\jdk-8u102-windows-x64\.rsrc\1033\JAVA_CAB10you will find 111 file.

         6.extract it it some folder where you can find tools.zip again extract that to some folder say Java & copy it to very first folder of setup along with .data,.rsrc etc.
         7.Go to folder where you have co…

GOF Design pattern with Java & Real World Examples

What are design patterns? 

So basically these are just collection of best practices to solve recurring problem by different kind of class arrangement. These arrangement could be based on creation of object or structural basis or on basis of required behavior.




Creational Design Pattern
Prototype Designpattern we will like to use this designpattern whenever creation of initial object & setting required default values is costly. So we just create 1 object & later on whenever more objects required we can provide initial object by just cloning of given object.Java Example is java.lang.Object#clone()
Builder DesignPattern When we jave object structure are complex and complicated we would go for this. we will be separating object creation from internal representation. With help of some simple interface we would create complicated Object.
Singleton When we need one instance per JVM. Example : Java Run time environment Java.lang.System.  java.lang.StringBuilder, Spring Beans are singleton …