-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Can I check a method (not persisted properties)in a Criteria
PostPosted: Fri Dec 05, 2003 3:01 pm 
Newbie

Joined: Sun Nov 30, 2003 4:11 pm
Posts: 11
Hi,

I've started trying to use the Criteria API, and I've got a problem with my query. The table has a date field in VARCHAR format, and I have a wrapper format in my Java class returning a long (millis).

My method is call getFechaAltaMillis(), but if I try the following:

Code:
crit.add(Expression.gt("fechaAltaMillis", TimeInMillis)
list = crit.list();


I get:

Code:
unresolved property: fechaAltaMillis [null]


I've used this before in the HQL queries, and I wonder if it's not possible to access my methods in the Criteria API...

_
Jorge


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 3:08 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Criteria API does not access methods. It uses property name to translate query to access to the proper column with SQL. You do not have a column fechaAltaMillis in the database so this will not work.

Why don't you want to store date as date/datetime/timestamp/whatever "native" format instead of varchar?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 4:46 pm 
Newbie

Joined: Sun Nov 30, 2003 4:11 pm
Posts: 11
I'd love to do it... but I'm strictly restricted to the legacy model...

Seems like I will have to stick to the HQL, haven't I?

Thanks again, Gavin!

_
Jorge


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 6:14 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
I'm not sure if it works but I would try the following:

1. create special date-property with formula. Use your database specific function to convert your varchar representation to normal date. Something like

<property name="parsedDate" type="date" formula="TO_DATE(varchardatecolumn)" />

2. use Criteria API:
Date someDateObject;
// set someDateObject to the necessary date
... gt("parsedDate", someDateObject);


Again - not sure if it works...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 7:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is something I don't understand, are you telling that fechaAltaMillis isn't mapped as a property and you still can do "from Item item where item.fechaAltaMillis > :time" ?

If so Consider implementing a custom type.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 7:14 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Dimas, turn of your f***** SpamCop filter or I'll kick your account.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 7:35 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Very nice.

Guys, if you got listed by SpamCop RBL (or any other RBL) I think you should contact them in order to get unlisted not killing people who uses them.

Second: I think it is your, not my problem you are using some real mailbox as MAIL FROM for notification emails. You could easily setup something like bounces@hibernate.org which goes directly to /dev/null. Better solution would be of course using normal maillist manager which processes bounced messages and deactivates bouncing emails.

If my account fated to be killed only because of this wonderful incident - go on.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 4:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can't get off their list. Not only is the concept of blacklists flawed, but this service is extra broken. We are using a real mailbox as a FROM, in fact, there is no such thing as "real mailboxes" in SMTP. Bouncing e-mails are getting to me, which is in fact, a mailing list manager.

Sorry, but after like 10 or 20 bounce e-mails from your address, I got a bit tired. You have decided _not_ to receive e-mail from "possibly" blacklistet accounts. Thats your decision, but don't spam postmasters with those invalid rejections.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 4:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Another thing, dimas: I'm not really angry about you, I just think you should re-read how blacklists work before blocking. :)

But I'm really angry about the person who reported us to SpamCop. Being such a bullsh*t service, I'm not even told who it was.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.