Class Product
- java.lang.Object
-
- ejava.examples.ejbwar.inventory.bo.InventoryRepresentation
-
- ejava.examples.ejbwar.inventory.bo.Product
-
- All Implemented Interfaces:
Serializable
@Entity public class Product extends InventoryRepresentation
This class represents a specific product. It has been mapped to both the DB, XML, and JSON -- which is not that common to do and causes some conflict. JAX-RS originally only had to support JAXB (i.e., @Xml annotations) and each vendor added optional extensions to support alternate formats like JSON. One common approach was to apply the Xml-centric JAXB bindings to JSON marshaling. That is what was done by the Jackson JSON marshaler. Jackson also had annotations (@Json) that could override JAXB (@Xml) annotations. That is how things sat for < jee8. With jee8 and jax-rs 2.1, JSON-B was created and support mandated. This example was written before full jee8 compliance. Thus it has been annotated with JSOB-B annotations (@Jsonb) and Jackson (@Json) annotations so that it will work with both jee7 and jee8 deployments. The client will always be using JSON-B. The use of JAXB annotations for Json does confuse the marshaling decision logic. So we have to make sure we have JSON-B annotations on the class, and passed to the marshaling methods. Of course -- if your marshaled class is a true DTO, then there is much less need for overrides.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
FIND_BY_NAME
private int
id
private String
name
private Double
price
private String
protectedValue
private Integer
quantity
private static long
serialVersionUID
-
Fields inherited from class ejava.examples.ejbwar.inventory.bo.InventoryRepresentation
NAMESPACE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getId()
String
getName()
Double
getPrice()
String
getProtectedValue()
Integer
getQuantity()
void
setId(int id)
void
setName(String name)
void
setPrice(Double price)
void
setProtectedValue(String protectedValue)
void
setQuantity(Integer quantity)
String
toString()
Product
withProtectedValue(String string)
-
Methods inherited from class ejava.examples.ejbwar.inventory.bo.InventoryRepresentation
getVersion, setVersion
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
FIND_BY_NAME
public static final String FIND_BY_NAME
- See Also:
- Constant Field Values
-
id
private int id
-
name
private String name
-
quantity
private Integer quantity
-
price
private Double price
-
protectedValue
private String protectedValue
-
-
Method Detail
-
getId
public int getId()
-
setId
public void setId(int id)
-
getName
public String getName()
-
setName
public void setName(String name)
-
getQuantity
public Integer getQuantity()
-
setQuantity
public void setQuantity(Integer quantity)
-
getPrice
public Double getPrice()
-
setPrice
public void setPrice(Double price)
-
getProtectedValue
public String getProtectedValue()
-
setProtectedValue
public void setProtectedValue(String protectedValue)
-
-