What is the best type for storing IP-addresses in a database using Hibernate?
I though Byte[] or String, but is there a better way, or what do you use?
@Column(name = "range_from", nullable = false)
public Byte[] getRangeFrom() {
return rangeFrom;
}
public void setRangeFrom(Byte[] rangeFrom) {
this.rangeFrom = rangeFrom;
}
I store it in a long, very fast for lookup. You can use the following functions for conversion.
And this one
You may want to improve them by doing checks on the parameters.