Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Maheswar Sahu
How to configure for auto creation of Table with custom Schema?
26 settembre 2013 9.19
Risposta

Maheswar Sahu

Punteggio: New Member

Messaggi: 5

Data di Iscrizione: 28 aprile 2013

Messaggi recenti

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>
Maheswar Sahu
RE: How to configure for auto creation of Table with custom Schema?
26 settembre 2013 9.27
Risposta

Maheswar Sahu

Punteggio: New Member

Messaggi: 5

Data di Iscrizione: 28 aprile 2013

Messaggi recenti

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
David H Nebinger
RE: How to configure for auto creation of Table with custom Schema?
26 settembre 2013 19.48
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7860

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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.
Maheswar Sahu
RE: How to configure for auto creation of Table with custom Schema?
27 settembre 2013 8.54
Risposta

Maheswar Sahu

Punteggio: New Member

Messaggi: 5

Data di Iscrizione: 28 aprile 2013

Messaggi recenti

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.
David H Nebinger
RE: How to configure for auto creation of Table with custom Schema?
27 settembre 2013 10.35
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7860

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

nope, you're on the right path. now use your custom db connection for the entities in question and you should be golden.