[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] how to generate history table under the history policy
|
I'll try the session customer, and about the QueryHints it should pass in a
string, no matter the string is generated by a Date or Timestamp, is that
right?
Thank you very much. It real help me know the session customer better.
Regards,
Joe
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of José Arcángel
Salazar Delgado
Sent: Tuesday, October 26, 2010 2:26 AM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] how to generate history table under the
history policy
On Lun 25 Oct 2010 13:14:40 Joe(Zhou Xiangtao) escribió:
> Thanks for your reply, now I have another question. I use QueryHints.
> AS_OF to make a historical query.
>
> When I pass the date as hint parameter, and look at the sql under
> console, the date parameter always is 1970-01-01. Do you have any
> suggestion?
>
>
>
> Here is the code:
>
>
>
> TypedQuery<Consignee> query=em.createQuery("select c from Consignee c
> where c.id=?1", Consignee.class);
>
> query.setParameter(1,
> consignee.getId());
>
> SimpleDateFormat format=new
> SimpleDateFormat("yyyy/MM/dd HH:mm:ss.S");
>
> System.out.println(format.format(d));
>
> query.setHint(QueryHints.AS_OF,
> format.format(d));
>
>
> query.setHint(QueryHints.MAINTAIN_CACHE,
> false);
Try with the formatter from the javadoc:
eclipselink.history.as-of"
Configures the query to query the state of the object as-of a point in time.
This can only be used if the class has been configured with historical
support, or if Oracle Flashback is used. Valid values are timestamps in the
form "YYYY/MM/DD HH:MM:SS.n".
>
>
>
>
>
> And for your hint, about the Session customer, I didn't find a method
> to get the default Table creator, only table creator has the table
> definition. Could you give more detailed description?
You can use the postlogin SessionCustomizer. But beware, because the
customizer executes the queries before the create-tables statements. this is
a minimun example:
@Override
public void customize(Session session) throws Exception {
session.getEventManager().addListener(new
SessionEventAdapter() {
@Override
public void postLoginClientSession(SessionEvent
event) {
//Sql code here
}
}
});
}
>
>
>
> Regards,
>
> Joe
>
>
>
>
>
> -----Original Message-----
> From: eclipselink-users-bounces@xxxxxxxxxxx
> [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of José
> Arcángel Salazar Delgado
> Sent: Tuesday, October 26, 2010 12:27 AM
> To: EclipseLink User Discussions
> Subject: Re: [eclipselink-users] how to generate history table under
> the history policy
>
> On Lun 25 Oct 2010 01:46:12 Joe(Zhou Xiangtao) escribió:
> > Hi everyone,
> >
> >
> >
> >
> >
> >
> >
> > What I need is automatically generate history table, there is no
> >
> > obvious method to achieve this.
>
> Eclipselink doesn't have any method to automatic created the history
table.
>
> You need to manually create every table using some Session customizer.
>
> > About the JPA history, you can find it here:
> > <http://wiki.eclipse.org/EclipseLink/Examples/JPA/History>
>
> http://wiki.eclipse.org/EclipseLink/Examples/JPA/History
>
> > And about table generation, there is an old mail described it, but
> >
> > it's not clear, anyone can give a further description or demo code?
> >
> >
> > <http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05160.htm
> > l>
>
> http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05160.html
>
> > regards,
> >
> >
> >
> > Joe
>
> _______________________________________________
>
> eclipselink-users mailing list
>
> <mailto:eclipselink-users@xxxxxxxxxxx> eclipselink-users@xxxxxxxxxxx
>
> <https://dev.eclipse.org/mailman/listinfo/eclipselink-users>
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users