Fórumok

How to configure for auto creation of Table with custom Schema?

thumbnail
Maheswar Sahu, módosítva 10 év-val korábban

How to configure for auto creation of Table with custom Schema?

New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.04.29. Legújabb bejegyzések
Hi There,

I configured to different schema(booklib) using ext-spring.xml and created the same schema in database but table is not creating automatically but when connect to liferay schema(lportal) it creates the table automatically. can any one suggest how to configure to create auto table for different schema. Here is my ext-spring.xml

<?xml version="1.0"?>

<beans default-destroy-method="destroy" default-init-method="afterPropertiesSet"
xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="customDataSource"
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
<property name="propertyPrefix" value="jdbc.custom.default." />
</bean>
</property>
</bean>

<bean id="customHibernateSessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil"
factory-method="newBean">
<constructor-arg
value="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration" />
<constructor-arg>
<map>
<entry key="dataSource" value-ref="customDataSource" />
</map>
</constructor-arg>
</bean>
<bean id="customSessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil"
factory-method="newBean">
<constructor-arg
value="com.liferay.portal.dao.orm.hibernate.PortletSessionFactoryImpl" />
<constructor-arg>
<map>
<entry key="dataSource" value-ref="customDataSource" />
<entry key="sessionFactoryClassLoader" value-ref="portletClassLoader" />
<entry key="sessionFactoryImplementor" value-ref="customHibernateSessionFactory" />
</map>
</constructor-arg>
</bean>

<bean id="transactionAdvice" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil"
factory-method="newBean">
<constructor-arg
value="com.liferay.portal.spring.transaction.TransactionInterceptor" />
<constructor-arg>
<map>
<entry key="platformTransactionManager" value-ref="customTransactionManager" />
<entry key="transactionAttributeSource" value-ref="transactionAttributeSource" />
</map>
</constructor-arg>
</bean>

<bean id="customTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
lazy-init="true">
<property name="dataSource">
<ref bean="customDataSource" />
</property>
<property name="sessionFactory">
<ref bean="customHibernateSessionFactory" />
</property>
</bean>
</beans>
thumbnail
Maheswar Sahu, módosítva 10 év-val korábban

RE: How to configure for auto creation of Table with custom Schema?

New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.04.29. Legújabb bejegyzések
When i try to insert the record getting Exception
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: How to configure for auto creation of Table with custom Schema?

Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Service builder does not support schemas at all.

However, if you use separate login creds that have the default schema as the one you want, the table should get created in the right place.
thumbnail
Maheswar Sahu, módosítva 10 év-val korábban

RE: How to configure for auto creation of Table with custom Schema?

New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.04.29. Legújabb bejegyzések
Hi David,

Thanks for your reply.

Could you please explain how to use separate login creds to create the auto table in database.

I have used the following properties in portal-ext.properties.

#Access Detail for Liferay Database
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root

#Access Detail for Book Library Database
jdbc.custom.default.driverClassName=com.mysql.jdbc.Driver
jdbc.custom.default.url=jdbc:mysql://localhost:3306/booklib?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.custom.default.username=root
jdbc.custom.default.password=root

Correct me if i misunderstood.

I searched on net all and say that it need to create tables manually when pointing to another DB(other than Liferay pointed Demoticon. Is there any way to create auto tables in liferay with different DB.
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: How to configure for auto creation of Table with custom Schema?

Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
nope, you're on the right path. now use your custom db connection for the entities in question and you should be golden.