influxdb-java icon indicating copy to clipboard operation
influxdb-java copied to clipboard

does all tags defined in POJO need assign a value?

Open rtecarden opened this issue 6 years ago • 1 comments

I created a POJO to insert into influxdb:

@Measurement(name = "mymeasurement") public class Pojo {

@Column(name = "tag1", tag =true)
private string tag1;

@Column(name = "tag2", tag = true)
private String tag2;

@Column(name = "value")
private Double value;

public String getTag1() {
  return tag1;
}

public void setTag1(String tag) {
  this.tag1 = tag;
}

public String getTag2() {
  return tag2;
}

public void setTag2(String tag) {
  this.tag2 = tag;
}

public Double getValue() {
  return value;
}

public void setDoubleObject(Double v) {
  this.value = v;
}

}

when i create a object with out set all tags, it failed with null exception:

Pojo pojo = new Pojo(); pojo.SetTag1("tag1value"); pojo.setValue(1);

Long t = Instant.now().toEpochMilli(); Point point = Point.measurementByPOJO(pojo.getClass()).addFieldsFromPOJO(pojo).time(t,TimeUnit.MILLISECONDS).build();

influxDb.write(getDBName(), getRPName(), point);

java.lang.NullPointerException

     at org.influxdb.dto.Point.escapeKey(Point.java:471)

     at org.influxdb.dto.Point.concatenatedTags(Point.java:432)

     at org.influxdb.dto.Point.lineProtocol(Point.java:420)

my question is does all tag need to be assign a value?

rtecarden avatar May 16 '19 09:05 rtecarden

Hi,

I have the same request, if tag's value is null, is not possible to delete it?

nmazzon avatar May 28 '19 11:05 nmazzon