Hi Stefan,

It depends on in which context you are querying the database:

1. *Outside* the current transaction: Database changes are only visible for
other transactions (connections) after you've committed your current
transaction. You should commit the Context which will save all changes to
the database. To prevent the "lazy object initialisation error" when
accessing objects after that commit, you need to "reload" any entity
(object) that you still want to use (e.g.
https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-api/src/main/java/org/dspace/harvest/OAIHarvester.java#L445
)

2. *Within* the current transaction: If you keep using the Hibernate API,
Hibernate will make sure that you'll always see a consistent state. However
if you're using native SQL queries, I'm not sure Hibernate is able to
handle that. In that case, you can open your context in BATCH_EDIT mode (
https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportCLITool.java#L297).
This should tell Hibernate to *always* flush any changes immediately to the
database (but remember, still only visible within the current database
transaction).

Best regards,
Tom


[image: logo] Tom Desair
250-B Suite 3A, Lucius Gordon Drive, West Henrietta, NY 14586
Gaston Geenslaan 14, Leuven 3001, Belgium
www.atmire.com
<http://atmire.com/website/?q=services&utm_source=emailfooter&utm_medium=email&utm_campaign=tomdesair>

2017-07-25 10:32 GMT+02:00 Stefan Fritzsche <[email protected]>
:

> Hi,
>
> i try to set the status of an DSpaceObject in the database. When the
> status is set the objects has the right status but in the database is the
> old status. I try to fire an MODIFY event in the setter and after that i
> make a context.dispatchEvent() call but nothing happends in the DB. I also
> try to use context.commit but after this call i got a lazy object
> initialisation error.
>
> How can commit the changes immediately to database?
>
> Thanks,
> Stefan
>
> --
> Stefan Fritzsche
> Fachinformatiker/digitale Archivierung
>
> Technische Universität Dresden
> Zentrum für Informationsdienste und Hochleistungsrechnen
> Abt: Verteiltes und Datenintensives Rechnen
> 01062 Dresden
>
> Tel.: +49 351 463-33212
> E-Mail: [email protected]
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "DSpace Technical Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/dspace-tech.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Reply via email to