Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate - How to store java.net.URL into a database through Hibernate

Tags:

java

hibernate

I have a field URL countryURL; in a Country class. I want to store its data into a COUNTRY table in a database through Hibernate.

Which Hibernate type I should use in the hibernate mapping file

<property column="COUNTRY_URL" name="countryURL" type="..."/>

It is not excepting string and text type.

like image 242
Yatendra Avatar asked Dec 30 '25 19:12

Yatendra


1 Answers

You can create a org.hibernate.UserType for URL which maps to a varchar column. See Custom value types in the reference documentation.

like image 144
Lachlan Roche Avatar answered Jan 01 '26 09:01

Lachlan Roche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!