Any progress on this??

ps - Since I'm committing myself to moving our company to openjpa-slices I am very interested in any and all bugs with slices :) :) (though i'm not a developer in openjpa)



thiago ananias wrote:

Hello again Pinaki!

I'm running this simple test:

import java.util.*;
import javax.persistence.*;
import br.unicsul.model.*;
import br.unicsul.sistema.Utility;
import org.apache.openjpa.slice.SlicePersistence;

public class Main {

    public static void main(String args[]) {

        Properties props = new Properties();

        EntityManagerFactory factory =
Persistence.createEntityManagerFactory("PersistenceUnit", props);
        EntityManager em2 = factory.createEntityManager();

        Query q = em2.createQuery("select p from Livro p");
        q.setHint("openjpa.hint.slice.Target", "TWO");

        for (Livro v : (List<Livro>) q.getResultList()) {

            System.out.println("Returned Slice --> " +
SlicePersistence.getSlice(v));

            System.out.println("Retorno do BD --> " + v.getNome() + "
(created on: " + v.getDtInsert() + ")"); System.out.println("Retorno JSON --> " + Utility.toJSON(v));

        }

        em2.close();
        factory.close();

    }

}


if i put the hint "TWO" the program return this message
2027  PersistenceUnit.ONE  TRACE  [main] openjpa.jdbc.SQL - <t 16916276,
conn 5156931> executing prepstmnt 17226426 SELECT t0.id, t0.DTYPE, t0.db,
t0.dt_insert, t0.tx_descricao, t0.vc_destaque, t0.vl_estoque, t0.vc_nome,
t0.vl_preco, t1.id, t1.db, t1.dt_insert, t1.vc_nome, t2.id, t2.db,
t2.dt_insert, t2.vc_nome, t0.it_ano, t0.it_edicao, t3.id, t3.db,
t3.dt_insert, t3.vc_logo, t3.vc_nome, t3.vc_site, t0.vc_isbn, t0.it_paginas
FROM produto t0 LEFT OUTER JOIN secao t1 ON t0.pai = t1.id LEFT OUTER JOIN
editora t3 ON t0.editora = t3.id LEFT OUTER JOIN secao t2 ON t1.pai = t2.id
WHERE t0.DTYPE = ? [params=(String) Livro]

if i put the hint "TWO" the program return this message
1411  PersistenceUnit.ONE  TRACE  [main] openjpa.jdbc.SQL - <t 16916276,
conn 5156931> executing prepstmnt 4579880 SELECT t0.id, t0.DTYPE, t0.db,
t0.dt_insert, t0.tx_descricao, t0.vc_destaque, t0.vl_estoque, t0.vc_nome,
t0.vl_preco, t1.id, t1.db, t1.dt_insert, t1.vc_nome, t2.id, t2.db,
t2.dt_insert, t2.vc_nome, t0.it_ano, t0.it_edicao, t3.id, t3.db,
t3.dt_insert, t3.vc_logo, t3.vc_nome, t3.vc_site, t0.vc_isbn, t0.it_paginas
FROM produto t0 LEFT OUTER JOIN secao t1 ON t0.pai = t1.id LEFT OUTER JOIN
editora t3 ON t0.editora = t3.id LEFT OUTER JOIN secao t2 ON t1.pai = t2.id
WHERE t0.DTYPE = ? [params=(String) Livro]

if i put the hint "ONE, TWO" the program return this message
1296  PersistenceUnit.ONE  TRACE  [main] openjpa.jdbc.SQL - <t 1256167, conn
6666040> executing prepstmnt 15021407 SELECT t0.id, t0.DTYPE, t0.db,
t0.dt_insert, t0.tx_descricao, t0.vc_destaque, t0.vl_estoque, t0.vc_nome,
t0.vl_preco, t1.id, t1.db, t1.dt_insert, t1.vc_nome, t2.id, t2.db,
t2.dt_insert, t2.vc_nome, t0.it_ano, t0.it_edicao, t3.id, t3.db,
t3.dt_insert, t3.vc_logo, t3.vc_nome, t3.vc_site, t0.vc_isbn, t0.it_paginas
FROM produto t0 LEFT OUTER JOIN secao t1 ON t0.pai = t1.id LEFT OUTER JOIN
editora t3 ON t0.editora = t3.id LEFT OUTER JOIN secao t2 ON t1.pai = t2.id
WHERE t0.DTYPE = ? [params=(String) Livro]
1298  PersistenceUnit.ONE  TRACE  [main] openjpa.jdbc.SQL - <t 1256167, conn
6666040> [1 ms] spent
1067  PersistenceUnit.TWO  TRACE  [main] openjpa.jdbc.SQL - <t 1256167, conn
2889719> executing prepstmnt 28220074 SELECT t0.id, t0.DTYPE, t0.db,
t0.dt_insert, t0.tx_descricao, t0.vc_destaque, t0.vl_estoque, t0.vc_nome,
t0.vl_preco, t1.id, t1.db, t1.dt_insert, t1.vc_nome, t2.id, t2.db,
t2.dt_insert, t2.vc_nome, t0.it_ano, t0.it_edicao, t3.id, t3.db,
t3.dt_insert, t3.vc_logo, t3.vc_nome, t3.vc_site, t0.vc_isbn, t0.it_paginas
FROM produto t0 LEFT OUTER JOIN secao t1 ON t0.pai = t1.id LEFT OUTER JOIN
editora t3 ON t0.editora = t3.id LEFT OUTER JOIN secao t2 ON t1.pai = t2.id
WHERE t0.DTYPE = ? [params=(String) Livro]
1069  PersistenceUnit.TWO  TRACE  [main] openjpa.jdbc.SQL - <t 1256167, conn
2889719> [1 ms] spent


So i don't understand what's happening... my XML it's here:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <persistence-unit name="PersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>br.unicsul.model.Global</class>
    <class>br.unicsul.model.Produto</class>
    <class>br.unicsul.model.Livro</class>
    <class>br.unicsul.model.Editora</class>
    <class>br.unicsul.model.Autor</class>
    <class>br.unicsul.model.Secao</class>
    <class>br.unicsul.model.Cliente</class>
    <class>br.unicsul.model.Pedido</class>
    <class>br.unicsul.model.PedidoItem</class>
    <properties>
      <!-- TURN ON THE SLICES -->
      <property name="openjpa.BrokerFactory" value="slice"/>
      <property name="openjpa.slice.Names" value="ONE, TWO"/>
      <property name="openjpa.slice.Master" value="ONE"/>
      <property name="openjpa.slice.DistributionPolicy"
value="br.unicsul.sistema.DistributionRules"/>
      <!-- TURN ON THE SLICES -->
      <!-- THE SLICES DEFAULT SLICE -->
      <property name="openjpa.ConnectionURL"
value="jdbc:sqlserver://TANANIAS-D\SQLEXPRESS;database=cadastro;user=sa;password=testando123"/>
      <property name="openjpa.ConnectionDriverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <!-- THE SLICES DEFAULT SLICE -->
      <!-- SQLServer, the first Slice -->
      <property name="openjpa.slice.ONE.ConnectionURL"
value="jdbc:sqlserver://TANANIAS-D\SQLEXPRESS;database=cadastro;user=sa;password=testando123"/>
      <property name="openjpa.slice.ONE.ConnectionDriverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <!-- SQLServer, the first Slice -->
      <!-- MySql the second Slice -->
      <property name="openjpa.slice.TWO.ConnectionURL"
value="jdbc:mysql://localhost:3306/cadastro"/>
      <property name="openjpa.slice.TWO.ConnectionDriverName"
value="com.mysql.jdbc.Driver"/>
      <property name="openjpa.slice.TWO.ConnectionUserName" value="root"/>
      <property name="openjpa.slice.TWO.ConnectionPassword" value="sa"/>
      <!-- MySql the second Slice -->
<!-- CONFIGURATION FOR CREATE A CLEAN DATABASE <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction=&apos;add&apos;)"/>
      <property name="openjpa.slice.TWO.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction=&apos;add&apos;)"/>
      <property name="openjpa.slice.ONE.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction=&apos;add&apos;)"/>
       CONFIGURATION FOR CREATE A CLEAN DATABASE -->

      <!-- SHOW LOGs -->
      <property name="openjpa.Log" value="DefaultLevel=WARN, Enhance=TRACE,
SQL=TRACE"/>
      <property name="openjpa.slice.ONE.Log" value="DefaultLevel=WARN,
Enhance=TRACE, SQL=TRACE"/>
      <property name="openjpa.slice.TWO.Log" value="DefaultLevel=WARN,
Enhance=TRACE, SQL=TRACE"/>
      <!-- SHOW LOGs -->
    </properties>
  </persistence-unit>
</persistence>


Thanks for the help!

Regards

Thiago Ananias








Pinaki Poddar wrote:
Hi,
  I have verified hints against OpenJPA test bucket [1] and I do not see
any error.
  org.apache.openjpa.slice.TestQuery.java#testHint().

  May be you can post a small test with the persistence.xml?



thiago ananias wrote:


Pinaki Poddar wrote:
Hi,
I put the Slice "ONE", but when i remove the "hint" clause the result
comes for me, but i know that at least one result have to return in this query, i don't know what i'am
doing wrong...
Your question is not clear to me. 1. Please explain further
  2. Examine the generated SQL. Each executed SQL is logged with the
slice name it has been executed on. When you query with or without the
hint -- what SQLs do you see? On which slices are these SQLs being
executed?
OK, let explain the problem!

I'm making a targered query
        Query query = em.createQuery("SELECT c FROM Cliente c WHERE
c.email = :email AND c.senha = :senha");
        query.setParameter("email", email);
        query.setParameter("senha", senha);
        query.setHint("openjpa.hint.slice.Target", "TWO");

With this query i want the results of the Slice named "TWO" but the SQL
log sent this for me:

"2078  PersistenceUnit.ONE  TRACE  [http-8084-1] openjpa.jdbc.SQL - <t
21111684, conn 11387974> executing prepstmnt 2867588 SELECT t0.id, t0.db,
t0.dt_insert, t0.vc_bairro, t0.vc_cep, t0.vc_cidade, t0.vc_complemento,
t0.dt_nascimento, t0.vc_email, t0.vc_endereco, t0.vc_estado, t0.vc_nome,
t0.vc_numero, t0.vc_rg, t0.vc_senha, t0.vc_sexo, t0.vc_telefone FROM
cliente t0 WHERE (t0.vc_email = ? AND t0.vc_senha = ?) [params=(String)
[EMAIL PROTECTED], (String) 010203]"

I put Slice two in the query but it returns for me the slice one...what
i'm doing wrong?

Regards

Thiago Ananias














Reply via email to