Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:27:48+00:00 2026-05-27T04:27:48+00:00

I have a database table where I store URLs ( http://google.com for example). The

  • 0

I have a database table where I store URLs (http://google.com for example). The entity corresponding to the table has a URL type field, so I create a criteria query like the following:

CriteriaBuilder cb = ...
Path<URL> path = ...
cb.equal(path , new URL("http://google.com"));

This works as intended, however I want to be able to do something like this:

cb.like(path.<String>get("externalForm"), "%google%");

Obviously URL hasn’t got an externalForm field, but has a toExternalForm() method instead.

Is this kind of query possible with the API? If yes: how? Or is my best bet to map the URL column to String instead of URL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:27:48+00:00Added an answer on May 27, 2026 at 4:27 am

    No, you cannot call methods of persisted values in Criteria queries. JPQL do have same limitation. In the end both of those translate to the SQL query and calling method in arbitrary Java object does not fit too well in.

    Also in your case it does not matter do we try to access this via field or method. Reason being that fields in java.net.URL are different from the persistent attributes mapped in your entities. URL fields are not directly persisted (so you cannot query them in SQL), Serializable objects are just persisted via serialization to byte array or similar.

    Also, calling equals in java.net.URL can cause surprises: java.net.url Javadoc

    Just go with the String as type and keep care that field in database is long enough also for surprisingly long urls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table which contains an unsigned integer field to store the
I have a database table A which stores records, A has a primary key
I have a mysql database table to store country name and currency symbol -
I have a database that is similar to the following: create table Store(storeId) create
I have a mysql database table that will store locations for buildings and events
I have a MySQL database table that stores the URLs of photos. I need
I need to store potentially 100s of millions URLs in a database. Every URL
I have a BirthDate column in MySQL database table to store user's date of
I have a database table which stores a type for a project which stores
I have a database that contains a table for storing URL Images (since storing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.