HI,
I have an object which has a piece of URL-Information associated with it. Currently I save this URL in a simple String property, but java.net.URL would provide
You can also use JPA AttributeConverter such as explain here to map a URL object into a String column (Hibernate does that out of the box)
Or, if you are only interrested in validation, you may use BeanValidation. There is a @URL annotation in HibernateValidator extension you can also create your own constraint such as explain here
I personnaly prefer the BeanValidation solution because considering url as java.net.URL bring some complexity : need for JPA AttributeConverter, JSF Converter, JAXB Adapter... while it is just for validation