New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querydsl-collection doesn't support Joda Time #128

Closed
Vladislav-Hloboshin opened this Issue Apr 16, 2012 · 14 comments

Comments

Projects
None yet
2 participants
@Vladislav-Hloboshin

Hello,
please add support Joda Time in com.mysema.query.collections.ColQueryFunctions. At now I see only support for java.util.Date.
I manualy add this code in local source for my task:


public static int getMonth(DateTime dt){
        return dt.getMonthOfYear();
    }
public static int getYear(DateTime dt){
        return dt.getYear();
    }

And I would glad to see this code in next version

Sorry for my English.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 19, 2012

Member

I don't want to add a Joda Time dependency to Querydsl Collections, but you can easily support JodaTime in your queries by extending ColQueryTemplates and redefining the operations you need

add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");
add(Ops.DateTimeOps.YEAR, "{0}.getYear()");

Let me know if that works

Member

timowest commented Apr 19, 2012

I don't want to add a Joda Time dependency to Querydsl Collections, but you can easily support JodaTime in your queries by extending ColQueryTemplates and redefining the operations you need

add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");
add(Ops.DateTimeOps.YEAR, "{0}.getYear()");

Let me know if that works

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 24, 2012

Member

Did you have the chance to try this out?

Member

timowest commented Apr 24, 2012

Did you have the chance to try this out?

@Vladislav-Hloboshin

This comment has been minimized.

Show comment
Hide comment
@Vladislav-Hloboshin

Vladislav-Hloboshin Apr 24, 2012

Sorry, there was no time to try this out.

ColQueryTemplates is a final class. How I can extend it?
And if I extend ColQueryTemplates class, how I can link it to existing querydsl package library?

At first I tried:

ColQueryTemplates.DEFAULT.add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");

but 'add' method is private or protected, and I can't call it when my application initialized

Please, explain me what am I doing wrong.

Sorry for my English.

Sorry, there was no time to try this out.

ColQueryTemplates is a final class. How I can extend it?
And if I extend ColQueryTemplates class, how I can link it to existing querydsl package library?

At first I tried:

ColQueryTemplates.DEFAULT.add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");

but 'add' method is private or protected, and I can't call it when my application initialized

Please, explain me what am I doing wrong.

Sorry for my English.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 27, 2012

Member

Now it should work. Here is an example

    ColQueryTemplates templates = new ColQueryTemplates() {{
        add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");
        add(Ops.DateTimeOps.YEAR, "{0}.getYear()");
    }};
    ColQuery query = new ColQueryImpl(templates);
Member

timowest commented Apr 27, 2012

Now it should work. Here is an example

    ColQueryTemplates templates = new ColQueryTemplates() {{
        add(Ops.DateTimeOps.MONTH, "{0}.getMonthOfYear()");
        add(Ops.DateTimeOps.YEAR, "{0}.getYear()");
    }};
    ColQuery query = new ColQueryImpl(templates);
@Vladislav-Hloboshin

This comment has been minimized.

Show comment
Hide comment
@Vladislav-Hloboshin

Vladislav-Hloboshin Apr 27, 2012

Thanks, but I review code and saw this:

public ColQueryImpl(ColQueryTemplates templates) {
        this(new DefaultQueryEngine(new DefaultEvaluatorFactory(ColQueryTemplates.DEFAULT)));
    }

I don't see where is used 'templates' param. I think must be like this:

        this(new DefaultQueryEngine(new DefaultEvaluatorFactory(templates)));

Correct me if I wrong

Thanks, for your help. And sorry for my English again:)

Thanks, but I review code and saw this:

public ColQueryImpl(ColQueryTemplates templates) {
        this(new DefaultQueryEngine(new DefaultEvaluatorFactory(ColQueryTemplates.DEFAULT)));
    }

I don't see where is used 'templates' param. I think must be like this:

        this(new DefaultQueryEngine(new DefaultEvaluatorFactory(templates)));

Correct me if I wrong

Thanks, for your help. And sorry for my English again:)

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 27, 2012

Member

Yes, you are right. And no need to apologize for your English. It's good enough ;)

Member

timowest commented Apr 27, 2012

Yes, you are right. And no need to apologize for your English. It's good enough ;)

timowest added a commit that referenced this issue Apr 27, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 27, 2012

Member

Fixed

Member

timowest commented Apr 27, 2012

Fixed

@Vladislav-Hloboshin

This comment has been minimized.

Show comment
Hide comment
@Vladislav-Hloboshin

Vladislav-Hloboshin Apr 27, 2012

Thanks.
I'll try to check it out tomorrow

Thanks.
I'll try to check it out tomorrow

timowest added a commit that referenced this issue Apr 27, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 27, 2012

Member

I just implemented JodaTime support for you. Use it like this

ColQuery query = new ColQueryImpl(JodaTimeTemplates.DEFAULT);

This implementation doesn't have a compile time dependency on Joda Time

Member

timowest commented Apr 27, 2012

I just implemented JodaTime support for you. Use it like this

ColQuery query = new ColQueryImpl(JodaTimeTemplates.DEFAULT);

This implementation doesn't have a compile time dependency on Joda Time

@Vladislav-Hloboshin

This comment has been minimized.

Show comment
Hide comment
@Vladislav-Hloboshin

Vladislav-Hloboshin Apr 28, 2012

Sorry for off-topic, but when I can find last build with this commit?
Or I need to complile querydsl myself?

Sorry for off-topic, but when I can find last build with this commit?
Or I need to complile querydsl myself?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 28, 2012

Member

I just deployed the latest version 2.5.0.BUILD-SNAPSHOT to our snapshot repository https://source.mysema.com/maven2/snapshots

Member

timowest commented Apr 28, 2012

I just deployed the latest version 2.5.0.BUILD-SNAPSHOT to our snapshot repository https://source.mysema.com/maven2/snapshots

@Vladislav-Hloboshin

This comment has been minimized.

Show comment
Hide comment
@Vladislav-Hloboshin

Vladislav-Hloboshin May 1, 2012

It works!
Thanks for the fix and great library

It works!
Thanks for the fix and great library

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 1, 2012

Member

Good to hear. Thanks!

Member

timowest commented May 1, 2012

Good to hear. Thanks!

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 25, 2012

Member

Released in 2.6.0

Member

timowest commented May 25, 2012

Released in 2.6.0

@timowest timowest closed this May 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment