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

  • Home
  • SEARCH
  • 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 9127425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:16:46+00:00 2026-06-17T07:16:46+00:00

I am using Joda DateTime and the UserType library for hibernate 4 I have

  • 0

I am using Joda DateTime and the UserType library for hibernate 4

I have a JPA entity with the following field

@Columns(columns = { @Column(name = "lastUsedDateTimeStamp"), @Column(name = "lastUsedDateTimeStamp_TMZ") })
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTimeAsString")
private DateTime lastUsedDateTimeStamp;

I am using a normal Spring Data JPA repository as follows:

return repository.findAll(new PageRequest(0, 5, new Sort(Sort.Direction.DESC, “lastUsedDateTimeStamp”))).getContent();

However when I look at the sql that hibernate throws out in the logs it end as follows:

order by
        entity.lastUsedDateTimeStamp,
        entity.lastUsedDateTimeStamp_TMZ asc limit ?

This means that the sorting is not working on the lastUsedDateTimeStamp column as expected, as the “asc” keyword is after lastUsedDateTimeStamp_TMZ instead of lastUsedDateTimeStamp.

Does anyone know how I can fix it so that the query specifies “asc” on the correct field?

  • 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-17T07:16:48+00:00Added an answer on June 17, 2026 at 7:16 am

    Solved this one myself,
    had to write my own custom PersistentDateTimeAsString and AbstractMultiColumnDateTime classes that reversed the default order of the 2 fields.

    timezone is now first in the order and then date time.
    So the sql now looks like this:

    order by
            entity.lastUsedDateTimeStamp_TMZ,
            entity.lastUsedDateTimeStamp asc limit ?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Hibernate & Joda Time, with support from the UserType library. I'm able
We are using Hibernate 3.6.x and Joda-time, persisting DateTime with a org.jadira.usertype.dateandtime.joda.PersistentDateTimeWithZone like so:
I have a Joda-DateTime field in my model and want to display it formatted
I want to parse a DateTime using the joda library (in scala, but should
I am currently trying to persist Joda Time in Hibernate using usertype , but
I'm using the org.jadira.usertype.dateandtime.joda.PersistentDateTime class from UserType 3.0.0.RC1 to map a JodaTime DateTime to
I am using the Joda-Time library in Java, and have a date and time
I have the following problem using Joda-Time for parsing and producing date and time
I have the following code below, I'm trying to compare two dates using Joda
I'm using the Joda time (1.6) libraries and it keeps returning DateTime objects with

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.