Foren

Problems extending tables in another database

Carlos Fdo. Afanador M., geändert vor 13 Jahren.

Problems extending tables in another database

New Member Beiträge: 14 Beitrittsdatum: 26.06.09 Neueste Beiträge
Hi everyone...

I need some help. I'm extending the calendar portlet, but i have one problem when i'm saving the data in the extended database, the configuration i'm using is:

Liferay Portal Standard Edition 5.2.3 (Augustine / Build 5203 / May 20, 2009)
lportal database in Postgres 8.3
custom datatable in Mysql 5.1
JBoss_5_0_0_GA

1) Now, for extend the calendar portlet, i have an additional datasource pointing to my extension database:

<local-tx-datasource>
     <jndi-name>jdbc/XDS</jndi-name>
     <connection-url>jdbc:mysql://localhost:3306/anotherdatabase?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      <password>rootpass</password>
      <min-pool-size>0</min-pool-size>
</local-tx-datasource>



2) I made changes in the ext-spring.xml adding the bean to the portal recognice the second datasource:

<bean id="trainingDataSourceTarget" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean" lazy-init="true">
   <property name="jndiName">
      <value>jdbc/XDS</value>
   </property>
</bean>
<bean id="trainingDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" lazy-init="true">
   <property name="targetDataSource">
      <ref bean="trainingDataSourceTarget" />
   </property>
</bean>
<bean id="trainingHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortalHibernateConfiguration" lazy-init="true">
   <property name="dataSource">
	<ref bean="trainingDataSource" />
   </property>
</bean>
<bean id="trainingSessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl" lazy-init="true">
   <property name="sessionFactoryImplementor">
      <ref bean="trainingHibernateSessionFactory" />
   </property>
</bean>
<bean id="trainingTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" lazy-init="true">
   <property name="dataSource">
	<ref bean="trainingDataSource" />
   </property>
   <property name="sessionFactory">
      <ref bean="trainingHibernateSessionFactory" />
   </property>
</bean>

3) Finnaly i made a service.xml to create one table in my personal database (Mysql) to extend de liferay's calevent table, the structure of my service is:

<!--?xml version="1.0"?-->


<service-builder package-path="com.xxx.package">
	<namespace>NAME</namespace>
	<entity name="newcaleventext" local-service="true" remote-service="true" data-source="trainingDataSource" session-factory="trainingSessionFactory" tx-manager="trainingTransactionManager">

		<!-- PK fields -->

		<column name="id" type="long" primary="true" />

		<!-- Audit fields -->

		<column name="companyid" type="String" />
		<column name="groupid" type="String" />

		<!-- Other fields -->

		<column name="active" type="boolean" />

		<!-- Order -->

		<order by="asc">
			<order-column name="id" case-sensitive="false" />
		</order>

		<!-- Finder methods -->

		<finder name="CompanyAndGroup" return-type="Collection">
			<finder-column name="companyid" />
			<finder-column name="groupid" />
		</finder>
	</entity>
        <exceptions>
		<exception>AnotherCalendarException</exception>	
	</exceptions>
</service-builder>

4) The i modify my XLocalServiceImpl.java adding a single method that return a list of this elements:

public Lis&lt;...model.X&gt; getAll(){
    return xPersistence.findAll();
}

And re-run the ant target for my service, but when execute the method of insertion i have an exception:

ERROR [JDBCExceptionReporter] Unknown column 'x0_.id_' in 'field list'

And no returns me nothing, can anyone help me please...I don't know what error has this extension.

PD... When i made a insertion i have the error:


2010-08-26 12:18:02,011 INFO  [STDOUT] (http-127.0.0.1-8080-1) 12:18:02,011 ERROR [JDBCExceptionReporter] Unknown column 'id_' in 'field list'
2010-08-26 12:18:02,370 INFO  [STDOUT] (http-127.0.0.1-8080-1) 12:18:02,370 ERROR [jsp] com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Could not execute JDBC batch update


Thanks in advice
thumbnail
Zankar Shah, geändert vor 13 Jahren.

RE: Problems extending tables in another database

Regular Member Beiträge: 106 Beitrittsdatum: 03.10.07 Neueste Beiträge
I think better idea would be using same database but just extra one more table having one to one relationship with calevent table.
Carlos Fdo. Afanador M., geändert vor 13 Jahren.

RE: Problems extending tables in another database

New Member Beiträge: 14 Beitrittsdatum: 26.06.09 Neueste Beiträge
Thanks for ur answer...

I solved the problem just adding in my service.xml the property db-name and then service builder recognized the diferent database:


<column name="companyId" db-name="companyid" type="String" />


Thanks a lot!!