Best type for IP-address in Hibernate Entity?
问题 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; } 回答1: I store it in a long , very fast for lookup. You can use the following functions for conversion. public static string GetStandardIP(long numericIP) { string w =