Reputation: 2985
I'm building a project with Hibernate 4.0, Java 8.
The goal of the project is to sync two database. Postgresql and Firebird.
I have a method called insertIntoFirebird() that get the values from Postgresql Table and insert them into the Firebird table.
public void insertIntoFirebid(){
sessionPostgresql.beginTransaction();
sessionFirebird.beginTransaction();
@SuppressWarnings("unchecked")
List<Profissional> profissional = sessionPostgresql.createQuery("SELECT P.NOME, P.CPF, P.RG, P.EMAIL, P.ENDERECO, P.UF from Profissional P Order by P.ID").list();
sessionPostgresql.close();
Query insert = sessionFirebird.createSQLQuery("insert into Conta values(profissional)");
sessionFirebird.update(insert);
sessionFirebird.close();
}
How can I use the values of profissional list as the values of the hql insert ?
Upvotes: 0
Views: 699
Reputation: 578
You could iterate over your result list and save professional by calling sessionFirebird.save()
inside of transaction. Also take a look here
Upvotes: 1