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 8950105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:22:36+00:00 2026-06-15T13:22:36+00:00

I am trying to return spatial data (ie Point) from database using Hibernate Spatial

  • 0

I am trying to return spatial data (ie Point) from database using Hibernate Spatial library (http://www.hibernatespatial.org/) using this WORKING approach…

    ... 
    Session session = sessionFactory.openSession();
    Query query = session.createQuery("select location, distance(location, :requestPoint) from "+Event.class.getName());
    query.setParameter("requestPoint", requestPoint);

    List<?> rows = query.list();
    session.close();

    List<Event> events = new ArrayList<Event>();

    for (Iterator<?> it = rows.iterator(); it.hasNext(); ) {
       Object[] row = (Object[]) it.next();

       Event event = new Event();
       event.setLocation((Point) row[0]);
       event.setDistance((Double) row[1]);

       events.add(event);
    }

    return events;

but I would like to use something like this (use Event class constructor in select statment)…

    Session session = sessionFactory.openSession();
    Query query = session.createQuery("select new Event(location, distance(location, :requestPoint)) from "+Event.class.getName());
    query.setParameter("requestPoint", requestPoint);

    List<Event> rows = query.list();
    session.close();

    return rows;

The problem is that the second approach gives me following exception…

org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [com.jaygridley.aet.Event] [select new Event(location, distance(location, :requestPoint)) from com.jaygridley.aet.domain.Event]

but I cannot see why, because inside of my Event class I have a constructor…

public Event(Point location, Double distance) {
    this.location = location;
    this.distance = distance;
}

for clarity Event class has following properties…

@Column(name="LOCATION", columnDefinition = "MDSYS.SDO_GEOMETRY", nullable = false)
@Type(type = "org.hibernate.spatial.GeometryType")
private Point location;

private Double distance;

I have checked return class for each column that Hibernate returns and it matches Point and Double. Does anyone has any idea what I am doing wrong? Thanks you!

  • 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-06-15T13:22:37+00:00Added an answer on June 15, 2026 at 1:22 pm

    Solved by using Object instead of Point in constructor for location parameter and casting to Point afterwards in constructor body.

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

Sidebar

Related Questions

I'm trying to return a single row from a database: using (connection = new
I am trying to return an array Data Member from one smaller 2D Array
Iam trying to return json data from codeigniter view. but my code is not
Im trying to return a list to a display template containing data from two
I'm trying to return the track href value from the spotify api using the
Hi I am trying to return two variables from a function using the following
im trying to return a local object from a function and i have this
When trying to return a simple set of results from my database table 'checklist'
I'm trying to return an html, page using out.print(); from a servlet, and I
trying to return data using OracleDataReader , getting Object reference not set to an

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.