I have a simple web-app with Database with two tables.
The administrators can modified the first table manually directly from SQL script (for example with PHPMyAdmin) and my web-app should be write into second tables some data after this edit.
Can I do it?
You can use the @PrePersist Annotation:
http://docs.oracle.com/javaee/5/api/javax/persistence/PrePersist.html
This will store a second entity into another table, if the first one is modified.
edit:
A trigger cannot start a JPA-code. That is not part of JPA.
A trigger within an Oracle Database may start a piece of Java Code as a java-trigger.
I assume you are using a mysql-database, so you’ll have to create a trigger at databaselevel an a timerservice which will poll the second table for changes.