I am getting errors in R.java when compiling my project.
I tried to solve it but I could not, does anyone help me?
R.java:
public static final int drawable/abc_btn_check_to_on_mtrl_000=0x7f07002c;
public static final int drawable/abc_btn_check_to_on_mtrl_015=0x7f07002d;
public static final int drawable/abc_btn_radio_to_on_mtrl_000=0x7f07002e;
public static final int drawable/abc_btn_radio_to_on_mtrl_015=0x7f07002f;
public static final int drawable/abc_btn_switch_to_on_mtrl_00001=0x7f070030;
public static final int drawable/abc_btn_switch_to_on_mtrl_00012=0x7f070031;
public static final int drawable/abc_ic_star_half_black_16dp=0x7f070032;
public static final int drawable/abc_ic_star_half_black_36dp=0x7f070033;
public static final int drawable/abc_ic_star_half_black_48dp=0x7f070034;
public static final int drawable/abc_list_focused_holo=0x7f070035;
public static final int drawable/abc_list_selector_background_transition_holo_dark=0x7f070036;
public static final int drawable/abc_list_selector_background_transition_holo_light=0x7f070037;
public static final int drawable/abc_list_selector_disabled_holo_dark=0x7f070038;
public static final int drawable/abc_list_selector_disabled_holo_light=0x7f070039;
public static final int drawable/abc_scrubber_control_off_mtrl_alpha=0x7f07003a;
public static final int drawable/abc_scrubber_control_to_pressed_mtrl_000=0x7f07003b;
public static final int drawable/abc_scrubber_control_to_pressed_mtrl_005=0x7f07003c;
public static final int drawable/abc_scrubber_primary_mtrl_alpha=0x7f07003d;
public static final int drawable/abc_scrubber_track_mtrl_alpha=0x7f07003e;
public static final int drawable/abc_tab_indicator_mtrl_alpha=0x7f07003f;
public static final int drawable/abc_textfield_activated_mtrl_alpha=0x7f070040;
public static final int drawable/abc_textfield_default_mtrl_alpha=0x7f070041;
public static final int drawable/abc_textfield_search_activated_mtrl_alpha=0x7f070042;
public static final int drawable/abc_textfield_search_default_mtrl_alpha=0x7f070043;
public static final int drawable/common_google_signin_btn_icon_dark_disabled=0x7f070044;
public static final int drawable/common_google_signin_btn_icon_dark_focused=0x7f070045;
public static final int drawable/common_google_signin_btn_icon_dark_normal=0x7f070046;
public static final int drawable/common_google_signin_btn_icon_dark_pressed=0x7f070047;
public static final int drawable/common_google_signin_btn_text_dark_disabled=0x7f070048;
public static final int drawable/common_google_signin_btn_text_dark_focused=0x7f070049;
public static final int drawable/common_google_signin_btn_text_dark_normal=0x7f07004a;
public static final int drawable/common_google_signin_btn_text_dark_pressed=0x7f07004b;
public static final int drawable/notification_bg_low_normal=0x7f07004c;
public static final int drawable/notification_bg_low_pressed=0x7f07004d;
public static final int drawable/notification_bg_normal_pressed=0x7f07004e;
public static final int drawable/notify_panel_notification_icon_bg=0x7f07004f;
public static final int edit_query=0x7f070050;
public static final int end=0x7f070051;
public static final int end_padder=0x7f070052;
public static final int expand_activities_button=0x7f070053;
public static final int expanded_menu=0x7f070054;
public static final int home=0x7f070055;
public static final int homeAsUp=0x7f070056;
public static final int icon=0x7f070057;
public static final int icon_group=0x7f070058;
public static final int icon_only=0x7f070059;
public static final int ifRoom=0x7f07005a;
public static final int image=0x7f07005b;
public static final int img_prog_frame=0x7f07005c;
public static final int info=0x7f07005d;
public static final int layout/notification_template_part_chronometer=0x7f07005e;
http://prntscr.com/k4uydg
http://prntscr.com/k4uygr
I have already looked for errors in strings.xml but found nothing.
Related
Person Class
public class Person implements java.io.Serializable{
private static final long serialVersionUID = 1L;
int id;
Address address;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
Person(int id, Address address){
this.id=id;
this.address=address;
}
}
Address Class
public class Address implements java.io.Serializable {
private static final long serialVersionUID = 1L;
String state;
String city;
CodeInfo codeInfo;
public CodeInfo getCodeInfo() {
return codeInfo;
}
public void setCodeInfo(CodeInfo codeInfo) {
this.codeInfo = codeInfo;
}
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 Address(String state, String city,CodeInfo codeInfo) {
this.state = state;
this.city = city;
this.codeInfo = codeInfo;
}
}
CodeInfo class
public class CodeInfo implements Serializable {
private static final long serialVersionUID = 1L;
String prop;
public String getProp() {
return prop;
}
public void setProp(String prop) {
this.prop = prop;
}
public CodeInfo(String prop) {
this.prop=prop;
}
}
JaversNewClass
public class JaversNewClass {
private static final ObjectMapper MAPPER = new ObjectMapper();
public static void main(String[] args) {
Diff diff =JaversInstance.getInstance().compare(
MAPPER.valueToTree(new Person(1,new Address("Delhi",null,new
CodeInfo(null)))),
MAPPER.valueToTree(new Person(2,new Address("Noida","SEZ",new
CodeInfo("abc"))))
);
System.out.println(diff.toString());
}
}
Diff:
* new object: com.fasterxml.jackson.databind.node.ObjectNode/#_children/address/_children/codeInfo/_children/prop
* changes on com.fasterxml.jackson.databind.node.ObjectNode/ :
- '_children/address/_children/city._value' property with value 'SEZ' added
- '_children/address/_children/codeInfo._children' map changes :
'prop' -> 'com.fasterxml.jackson.databind.node.ObjectNode/#_children/address/_children/city' changed to 'com.fasterxml.jackson.databind.node.ObjectNode/#_children/address/_children/codeInfo/_children/prop'
- '_children/address/_children/state._value' value changed from 'Delhi' to 'Noida'
- '_children/id._value' value changed from '1' to '2'
In the current scenario I have two JsonNodes which I am comparing through javers.
So firstly i need to know is it possible to compare the json nodes in this way.
Secondly, I need to know why i am getting the new object and irrelevant map change instead of the value change.
However it is able to detect the address changes properly. This case is detected when nested object is changed from null..
I have following Request body which I am trying to insert into the database:
{
"vin": "1HGCR2F3XFA027534",
"latitude": 41.803194,
"longitude": -88.144406,
"timestamp": "2017-05-25T17:31:25.268Z",
"fuelVolume": 1.5,
"speed": 85,
"engineHp": 240,
"checkEngineLightOn": false,
"engineCoolantLow": true,
"cruiseControlOn": true,
"engineRpm": 6300,
"tires": {
"frontLeft": 34,
"frontRight": 36,
"rearLeft": 29,
"rearRight": 34
}
}
I cannot insert it as Tires object is always mapped as null. I don't think the json object is able to map to tires object.
Here are snippets
In controller:
#RequestMapping(method = RequestMethod.POST, value = "/readings")
public void readVehicleStatus(#RequestBody VehicleStatus vehicleStatus){
vehicleStatusService.readVehicleStatus(vehicleStatus);
}
VehicleStatus.java
#Entity
public class VehicleStatus {
#Id
private String vin;
private Double latitude;
private Double longitude;
private Double fuelVolume;
private int speed;
private int engineHp;
private int engineRpm;
private boolean checkEngineLightOn;
private boolean engineCoolantLow;
private boolean cruiseControlOn;
#Embeded
private Tires tires;
/* getters and setters created */
}
Tires.java
#Embeddable
public class Tires {
#Id
#GeneratedValue(strategy= GenerationType.IDENTITY)
int id;
private int frontLeft;
private int frontRight;
private int rearLeft;
private int rearRight;
/* getters and setters included */
}
In your VehicleStatus the tires json property is named vehicleTire but in the json is named tires, that's why is always null, so you should add #JsonProperty(value="tires").
Here is the full code:
#Entity
public class VehicleStatus implements Serializable{
#Id
private String vin;
private Double latitude;
private Double longitude;
private Double fuelVolume;
private int speed;
private int engineHp;
private int engineRpm;
private boolean checkEngineLightOn;
private boolean engineCoolantLow;
private boolean cruiseControlOn;
#OneToOne(mappedBy = "vehicleStatus",cascade=CascadeType.ALL)
#JoinColumn(name = "id")
#JsonProperty(value="tires") // here is the key :)
private Tires vehicleTire;
// Getters && Setters
}
#Entity
public class Tires implements Serializable{
#Id
#GeneratedValue(strategy= GenerationType.IDENTITY)
Integer id;
private Integer frontLeft; // NB try always to use wrapper type rather than primitive in jpa
private Integer frontRight;
private Integer rearLeft;
private Integer rearRight;
#OneToOne
private VehicleStatus vehicleStatus;
// Getters && Setters
}
TiresRepository:
public interface TiresRepository extends JpaRepository<Tires, Integer>{
}
VehicleStatusRepository:
public interface VehicleStatusRepository extends JpaRepository<VehicleStatus, String>{
}
Example of controller :
#RestController
#RequestMapping
class MyController {
#Autowired
private VehicleStatusRepository vehicleStatusRepository;
#RequestMapping(method = RequestMethod.POST, value = "/readings")
public void readVehicleStatus(#RequestBody VehicleStatus vehicleStatus){
vehicleStatusRepository.saveAndFlush(vehicleStatus);
}
}
Main class :
#SpringBootApplication
#EnableAutoConfiguration
public class SpringStackOverflowSolutionApplication {
public static void main(String[] args) {
SpringApplication.run(SpringStackOverflowSolutionApplication.class, args);
}
}
NB: do not forget cascadeAll, else the tires object will not be saved in the database and you will get the following exception :
org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : package.VehicleStatus.vehicleTire -> package.Tires
I am using retrofit for making requests to my server. I am trying to use the same Model for multiple requests and I want to send different objects with different SerializedName.
My pojo looks like this:
public class BaseModel<T> implements Serializable {
#SerializedName("success")
#Expose
private boolean succcess;
#SerializedName("data")
#Expose private T data;
public boolean isSucccess() {
return succcess;
}
public void setSucccess(boolean succcess) {
this.succcess = succcess;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
How can I set my #SerializedName("data") in a dynamic way? Thank you all for your time!
Code sample:
public class BaseRequestModel<T> implements Serializable {
#SerializedName("success")
#Expose
private boolean success;
#Expose private T data;
public boolean isSucccess() {
return success;
}
public void setSucccess(boolean succcess) {
this.success = succcess;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
One of the objects that I am sending to BaseModel (as T data):
public class User implements Serializable {
transient String requestName = "user";
#SerializedName("id")
#Expose
private int id;
#SerializedName("owner_id")
#Expose private int ownerId;
#SerializedName("first_name")
#Expose private String firstName;
#SerializedName("middle_name")
#Expose private String middleName;
#SerializedName("last_name")
#Expose private String lastName;
#SerializedName("username")
#Expose private String username;
public String getRequestName() {
return requestName;
}
public void setRequestName(String requestName) {
this.requestName = requestName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOwnerId() {
return ownerId;
}
public void setOwnerId(int ownerId) {
this.ownerId = ownerId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
My custom serializer:
public class BaseRequestCustomSerializer<T> implements JsonSerializer<User> {
#Override
public JsonElement serialize(User src, Type typeOfSrc, JsonSerializationContext context) {
src.getRequestName();
return null;
}
}
I have to pass to the serializer instead of the specific object, since this is what my problem is all about. Any ideas? Thank you!
if you want to set #SerializedName("data") than you must be get same variable name from api response.
I have been going around in circles with this error and not sure why I am getting this.
Here is the mapping of Shipper class
#Entity
#Table(schema="SALONBOOKS",name="SHIPPER")
#AttributeOverride(name="id", column=#Column(name="SHIPPER_ID"))
public class Shipper extends SalonObject {
private static final long serialVersionUID = 1L;
private ShipperType name;//ShipperType.WALKIN;
#Column(name="SHIPPER_NAME")
#Enumerated(EnumType.STRING)
public ShipperType getName() {
return name;
}
public void setName(ShipperType name) {
this.name = name;
}
#Override
public Long getId(){
return id;
}
}
Here is Order class which references Shipper
#Entity
#Table(schema="SALONBOOKS",name="ORDER")
#AttributeOverride(name="id", column=#Column(name="ORDER_ID"))
public class Order extends SalonObject {
private static final long serialVersionUID = 1L;
private BigDecimal total= new BigDecimal(0.0);
private int numOfItems=0;
private BigDecimal tax= new BigDecimal(0.0);;
private String currency="USD";
private BigDecimal subTotal= new BigDecimal(0.0);
private PaymentMethod paymentMethod;
private Shipper shipper;
private OrderStatusType status;
private Appointment appointment ;
private Person person;
#Column(name="TOTAL")
public BigDecimal getTotal() {
return total;
}
public void setTotal(BigDecimal total) {
this.total = total;
}
#Column(name="NUM_OF_ITEMS")
public int getNumOfItems() {
return numOfItems;
}
public void setNumOfItems(int numOfItems) {
this.numOfItems = numOfItems;
}
#Column(name="TAX")
public BigDecimal getTax() {
return tax;
}
public void setTax(BigDecimal tax) {
this.tax = tax;
}
#Column(name="CURRENCY")
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
#Column(name="SUBTOTAL")
public BigDecimal getSubTotal() {
return subTotal;
}
public void setSubTotal(BigDecimal subTotal) {
this.subTotal = subTotal;
}
#ManyToOne
#JoinColumn(name="PAYMENT_METHOD_ID", insertable=false,updatable=false)
public PaymentMethod getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(PaymentMethod paymentMethod) {
this.paymentMethod = paymentMethod;
}
#ManyToOne
#JoinColumn(name="SHIPPER_ID", insertable=false,updatable=false)
public Shipper getShipper() {
return shipper;
}
public void setShipper(Shipper shipVia) {
this.shipper = shipVia;
}
#Column(name="STATUS")
#Enumerated(EnumType.STRING)
public OrderStatusType getStatus() {
return status;
}
public void setStatus(OrderStatusType status) {
this.status = status;
}
#ManyToOne
#JoinColumn(name="APPOINTMENT_ID", insertable=false,updatable=false)
public Appointment getAppointment() {
return appointment;
}
public void setAppointment(Appointment appointment) {
this.appointment = appointment;
}
#ManyToOne
#JoinColumn(name="PERSON_ID", insertable=false,updatable=false)
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
#Override
public Long getId(){
return id;
}
}
each of these extends:
#MappedSuperclass
public abstract class SalonObject implements Entity, Serializable {
private static final long serialVersionUID = 1L;
protected Long id;
protected DateTime createDate;
protected DateTime updateDate;
#Id
#GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
#Override
public boolean equals(Object obj) {
if (obj instanceof SalonObject
&& obj !=null){
return ObjectUtils.equals(this.id, ((SalonObject) obj).getId()) ;
}
return false;
}
#Column(name="CREATE_DATE")
public DateTime getCreateDate() {
return createDate;
}
public void setCreateDate(DateTime dateTime) {
this.createDate = dateTime;
}
#Column(name="UPDATE_DATE")
public DateTime getUpdateDate() {
return updateDate;
}
public void setUpdateDate(DateTime updateDate) {
this.updateDate = updateDate;
}
}
The stackTrace is ::
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: salonbooks.model.Shipper column: SHIPPER_ID (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:709)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:731)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:753)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:506)
at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1358)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1849)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
at salonbooks.core.HibernateConfiguration.sessionFactory(HibernateConfiguration.java:109)
removing the following method from Shipper and from Order worked to resolve this error
#Override
public Long getId(){
return id;
}
Because you are using property access, by overriding the base method (containing the mapping configuration) you will replace your base method mapping configuration with no config at all.
Using field access wouldn't have caused this issue, but the override would have been useless anyway. The id field should have private access too, so this method wouldn't compile if you change the access modifier.
I need a spring repository method that lets me get a list of Scene entities using a list of id's. When I try to refer to the Scene Id I get an error, saying it can't find the property called IdScene. I am using a custom query to do this. Is there something wrong with my query?
My Entity is
public class Scene implements Serializable
{
private long id_scene;
private Media media;
private int sceneNumber;
private int version;
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = IDENTITY)
#Column(name = "id_scene")
public long getIdScene() {
return id_scene;
}
public void setIdScene(long id_scene) {
this.id_scene = id_scene;
}
#ManyToOne
#JoinColumn(name = "id_media")
public Media getMedia() {
return this.media;
}
public void setMedia(Media media) {
this.media = media;
}
private List<Thumbnail> thumbnails = new ArrayList<Thumbnail>();
#OneToMany(mappedBy = "scene", cascade=CascadeType.ALL,
orphanRemoval=true)
#LazyCollection(LazyCollectionOption.FALSE)
public List<Thumbnail> getThumbnails() {
return this.thumbnails;
}
public void setThumbnails(List<Thumbnail> thumbnails) {
this.thumbnails = thumbnails;
}
public void addThumbnail(Thumbnail thumbnail) {
thumbnail.setScene(this);
this.thumbnails.add(thumbnail);
}
private Property property;
#OneToOne(mappedBy="scene", cascade=CascadeType.ALL,
orphanRemoval=true)
#LazyCollection(LazyCollectionOption.FALSE)
public Property getProperty() {
return property;
}
public void setProperty(Property property) {
this.property = property;
}
public void addProperty(Property property) {
property.setScene(this);
this.property = property;
}
#Column(name = "sceneNumber")
public int getSceneNumber() {
return sceneNumber;
}
public void setSceneNumber(int sceneNumber) {
this.sceneNumber = sceneNumber;
}
#Column(name = "version")
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
}
My repository:
public interface SceneRepository extends JpaRepository<Scene, Long> {
public final static String FIND_BY_ID_LIST = "SELECT s"
+ " FROM Scene s WHERE s.IdScene IN (:id)";
#Query(FIND_BY_ID_LIST)
public List<Scene> findByIdScene(#Param("id") List<Long> id);//, Pageable page);
}
try:
"SELECT s FROM Scene s WHERE s.idScene IN (:id)"
note lower case 'i' in 'idScene'"
This is because of the Java Bean naming convention, a property defined as:
public String getWibble() { return wibble; }
public void setWibble(String value) { wibble = value; }
defines wibble and not Wibble