Search code examples
javamysqlhibernatedelay

INSERT LOW_PRIORITY or INSERT DELAYED in Hibernate


How do I do a low_priority or delayed insert into a MySQL table with Hibernate?

In my logging routine I want to insert the log info to a table in my database for further analysis. But I don't care about how long it takes for the insert to be done, so usually I would say INSERT LOW_PRIORITY INTO LogEntry (level, title, full) VALUES ('Info', 'Title here', 'Full log'); If I have an entity LogEntry, how do I write or wire up my LogEntryDAO to do LOW_PRIORITY or DELAYED inserts and updates?

Cheers

Nik


Solution

  • There is a much simpler solution.

    Annotate my entity class with @SQLInsert(sql="INSERT LOW_PRIORITY INTO LogEntry (level, title, full) VALUES (?, ?,?)")

    Nice and elegant :-)