Set de many-to-many, Não consego salvar

1 resposta
J

quando eu mando fazer um get ele monta o select correto pegando do esquema certo mais quando eu mando salvar ele se perde e coloca o esquema padão…

<class name="br.com.tpd.prsigres.management.persistence.model.GrafosDadosUsuarioTO" table="USUARIO" schema="GESTOR_ASSOCIACOES">

		<id name="idUsuario" column="ID_USUARIO" type="int" length="10">
			<generator class="increment" />
		</id>
		
		<property name="description" type="java.lang.String" column="NM_USUARIO" length="50" />
		
        <set name="clientesAssoc" table="ASSOCIACOES" lazy="true" inverse="true" cascade="all,delete-orphan">
            <key column="ID_USUARIO"/>            
            <many-to-many class="br.com.tpd.prsigres.management.persistence.model.GrafosDadosClienteTO" />
        </set>
        
        <set name="sistemasAssoc" table="ASSOCIACOES" lazy="true" inverse="true" cascade="all,delete-orphan">
            <key column="ID_USUARIO"/>            
            <many-to-many class="br.com.tpd.prsigres.management.persistence.model.GrafosDadosSistemaTO" />
        </set>
		    
    </class>

TO…

public class GrafosDadosUsuarioTO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int idUsuario;

	private String description;
	
	private Set clientesAssoc = new HashSet();
	
	private Set sistemasAssoc = new HashSet();
        
        gets and sets....
}

outra problema também é
eu tenho uma tabela USUARIO e ASSOCIACOES e preciso que quando eu mende salvar um usuário eu escluir ele vá na tabela associacoes e insira ou remova eles lá, a tabala só tem id de usuarios, clientes e sistema…

por favor se qualque poder veficar isso…seria muito granto…

1 Resposta

J

segue o modelo… para que entendam melhor e o erro que esta dando da forma que esta…

SystemOut     O Hibernate:

select

grafosdado0_.ID_USUARIO as ID1_12_0_,

grafosdado0_.NM_USUARIO as NM2_12_0_

from

GESTOR_ASSOCIACOES.USUARIO grafosdado0_

where

grafosdado0_.ID_USUARIO=?

SystemOut     O Hibernate:

select

max(ID_USUARIO)

from

USERADM_INTRANET.USUARIO

[11/13/08 10:18:56:062 BRST] 00000063 JDBCException W   SQL Error: -204, SQLState: 42704

[11/13/08 10:18:56:078 BRST] 00000063 JDBCException E   USERADM_INTRANET.USUARIO is an undefined name.

[11/13/08 10:18:56:109 BRST] 00000063 JDBCException W   SQL Error: -727, SQLState: 56098

[11/13/08 10:18:56:156 BRST] 00000063 JDBCException E   An error occurred during implicit system action type 2.  Information returned for the error includes SQLCODE -204, SQLSTATE 42704 and message tokens USERADM_INTRANET.USUARIO.

[11/13/08 10:18:56:343 BRST] 00000063 JDBCException W   SQL Error: -727, SQLState: 56098

[11/13/08 10:18:56:359 BRST] 00000063 JDBCException E   An error occurred during implicit system action type 2.  Information returned for the error includes SQLCODE -204, SQLSTATE 42704 and message tokens USERADM_INTRANET.USUARIO.

[11/13/08 10:19:36:328 BRST] 00000063 SystemOut     O TPS: EXCEPTION: org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator

[11/13/08 10:19:36:328 BRST] 00000063 SystemOut     O TPS: EXCEPTION: br.com.tpd.framework.DAOException: org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator

[11/13/08 10:19:36:734 BRST] 00000063 SystemOut     O [2008-11-13 10:19:36,734|ERROR |SaveOrUpdateUserAction.execute():82]  #### Error insert RemoteException occurred in server thread; nested exception is:

java.rmi.MarshalException: CORBA MARSHAL 0x4942f896 No; nested exception is:

org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Mismatched serialization UIDs : Source (Rep. IDRMI:java.lang.Throwable:F8678B4F4D2EB705:D5C635273977B8CB) = D5C635273977B8CB whereas Target (Rep. ID RMI:br.com.tpd.framework.DAOException:7DFDC0413F49F03D:0000000000000001) = 0000000000000001  vmcid: IBM  minor code: 896  completed: No

[11/13/08 10:19:36:281 BRST] 00000063 SystemErr     R org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)

at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)

at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)

at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:186)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)

at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)

at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)

at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)

at br.com.tpd.prsigres.management.persistence.dao.ManagementDAO.insertAssociation(ManagementDAO.java:1323)

<img src="/uploads/3X/8/9/899b5e9f8dce6cbdd18c49b27b8e2d636fe46649.jpg.webp" width="690" height="500">
Criado 13 de novembro de 2008
Ultima resposta 13 de nov. de 2008
Respostas 1
Participantes 1