Fórumok

Creating many-to-many relationship with existing entites

Peter Hellstrand, módosítva 11 év-val korábban

Creating many-to-many relationship with existing entites

Regular Member Bejegyzések: 166 Csatlakozás dátuma: 2011.11.30. Legújabb bejegyzések
I am trying this code from the service.xml dtd but i does not work. What do I have to do to use other Entities then those defined in my service.xml.


If you are creating a mapping table for an entity defined in another
service.xml, you need to specify the full package path.

For example:

<column name="organizations" type="Collection" entity="com.liferay.portal.Organization" mapping-table="Foo_Organizations" />




build-service:
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
     [echo] May 12, 2012 5:12:51 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
     [echo] INFO: Global lib directory /Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/lib/ext/
     [echo] May 12, 2012 5:12:51 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
     [echo] INFO: Portal lib directory /Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/
     [echo] 17:12:51,121 INFO  [EasyConf:122] Refreshed the configuration of all components
     [echo] 17:12:51,390 INFO  [ConfigurationLoader:56] Properties for jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal loaded from [jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
     [echo] Building ImportantNews
     [echo] Building Shortcut
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/src/no/jerniagruppen/services/service/persistence/ShortcutPersistenceImpl.java
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/service/no/jerniagruppen/services/service/persistence/ShortcutPersistence.java
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/service/no/jerniagruppen/services/service/persistence/ShortcutUtil.java
     [echo] 17:12:56,048 ERROR [runtime:96] Template processing error: "Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce"
     [echo] Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] The problematic instruction:
     [echo] ----------
     [echo] ==&gt; list serviceBuilder.getMappingEntities(column.mappingTable) as mapColumn [on line 250, column 41 in com/liferay/portal/tools/servicebuilder/dependencies/model_impl.ftl]
     [echo] ----------
     [echo] Java backtrace for programmers:
     [echo] ----------
     [echo] freemarker.template.TemplateModelException: Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
     [echo] 	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
     [echo] 	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:310)
     [echo] 	at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:428)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.process(Environment.java:199)
     [echo] 	at freemarker.template.Template.process(Template.java:237)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:49)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:39)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._processTemplate(ServiceBuilder.java:4788)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModelImpl(ServiceBuilder.java:2201)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:657)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:430)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:146)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [echo] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [echo] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [echo] 	at org.apache.tools.ant.Task.perform(Task.java:348)
     [echo] 	at org.apache.tools.ant.Target.execute(Target.java:390)
     [echo] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [echo] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [echo] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [echo] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [echo] 	at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [echo] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
     [echo] Caused by: java.lang.NullPointerException
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(ServiceBuilder.java:1004)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:866)
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106)
     [echo] 	... 53 more
     [echo] Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] The problematic instruction:
     [echo] ----------
     [echo] ==&gt; list serviceBuilder.getMappingEntities(column.mappingTable) as mapColumn [on line 250, column 41 in com/liferay/portal/tools/servicebuilder/dependencies/model_impl.ftl]
     [echo] ----------
     [echo] Java backtrace for programmers:
     [echo] ----------
     [echo] freemarker.template.TemplateModelException: Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
     [echo] 	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
     [echo] 	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:310)
     [echo] 	at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:428)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.process(Environment.java:199)
     [echo] 	at freemarker.template.Template.process(Template.java:237)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:49)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:39)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._processTemplate(ServiceBuilder.java:4788)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModelImpl(ServiceBuilder.java:2201)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:657)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:430)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:146)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [echo] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [echo] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [echo] 	at org.apache.tools.ant.Task.perform(Task.java:348)
     [echo] 	at org.apache.tools.ant.Target.execute(Target.java:390)
     [echo] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [echo] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [echo] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [echo] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [echo] 	at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [echo] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
     [echo] Caused by: java.lang.NullPointerException
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(ServiceBuilder.java:1004)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:866)
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106)
     [echo] 	... 53 more

</init></init></init></init>
thumbnail
Danial Mustofa Habibi, módosítva 11 év-val korábban

RE: Creating many-to-many relationship with existing entites

Regular Member Bejegyzések: 141 Csatlakozás dátuma: 2011.11.01. Legújabb bejegyzések
Peter Hellstrand:
I am trying this code from the service.xml dtd but i does not work. What do I have to do to use other Entities then those defined in my service.xml.


If you are creating a mapping table for an entity defined in another
service.xml, you need to specify the full package path.

For example:

<column name="organizations" type="Collection" entity="com.liferay.portal.Organization" mapping-table="Foo_Organizations" />




build-service:
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
     [echo] May 12, 2012 5:12:51 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
     [echo] INFO: Global lib directory /Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/lib/ext/
     [echo] May 12, 2012 5:12:51 PM com.liferay.portal.kernel.log.Jdk14LogImpl info
     [echo] INFO: Portal lib directory /Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/
     [echo] 17:12:51,121 INFO  [EasyConf:122] Refreshed the configuration of all components
     [echo] 17:12:51,390 INFO  [ConfigurationLoader:56] Properties for jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal loaded from [jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties, jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
     [echo] Loading jar:file:/Users/phe/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
     [echo] Building ImportantNews
     [echo] Building Shortcut
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/src/no/jerniagruppen/services/service/persistence/ShortcutPersistenceImpl.java
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/service/no/jerniagruppen/services/service/persistence/ShortcutPersistence.java
     [echo] Writing /Users/phe/liferay/liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760/portlets/jernia-gruppen-portlet/docroot/WEB-INF/service/no/jerniagruppen/services/service/persistence/ShortcutUtil.java
     [echo] 17:12:56,048 ERROR [runtime:96] Template processing error: "Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce"
     [echo] Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] The problematic instruction:
     [echo] ----------
     [echo] ==&gt; list serviceBuilder.getMappingEntities(column.mappingTable) as mapColumn [on line 250, column 41 in com/liferay/portal/tools/servicebuilder/dependencies/model_impl.ftl]
     [echo] ----------
     [echo] Java backtrace for programmers:
     [echo] ----------
     [echo] freemarker.template.TemplateModelException: Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
     [echo] 	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
     [echo] 	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:310)
     [echo] 	at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:428)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.process(Environment.java:199)
     [echo] 	at freemarker.template.Template.process(Template.java:237)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:49)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:39)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._processTemplate(ServiceBuilder.java:4788)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModelImpl(ServiceBuilder.java:2201)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:657)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:430)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:146)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [echo] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [echo] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [echo] 	at org.apache.tools.ant.Task.perform(Task.java:348)
     [echo] 	at org.apache.tools.ant.Target.execute(Target.java:390)
     [echo] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [echo] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [echo] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [echo] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [echo] 	at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [echo] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
     [echo] Caused by: java.lang.NullPointerException
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(ServiceBuilder.java:1004)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:866)
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106)
     [echo] 	... 53 more
     [echo] Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] The problematic instruction:
     [echo] ----------
     [echo] ==&gt; list serviceBuilder.getMappingEntities(column.mappingTable) as mapColumn [on line 250, column 41 in com/liferay/portal/tools/servicebuilder/dependencies/model_impl.ftl]
     [echo] ----------
     [echo] Java backtrace for programmers:
     [echo] ----------
     [echo] freemarker.template.TemplateModelException: Method public java.util.List com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(java.lang.String) throws java.io.IOException threw an exception when invoked on com.liferay.portal.tools.servicebuilder.ServiceBuilder@75e8d4ce
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
     [echo] 	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
     [echo] 	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:310)
     [echo] 	at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:428)
     [echo] 	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
     [echo] 	at freemarker.core.Environment.visit(Environment.java:221)
     [echo] 	at freemarker.core.Environment.process(Environment.java:199)
     [echo] 	at freemarker.template.Template.process(Template.java:237)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:49)
     [echo] 	at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:39)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._processTemplate(ServiceBuilder.java:4788)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModelImpl(ServiceBuilder.java:2201)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:657)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:430)
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:146)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [echo] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [echo] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [echo] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [echo] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [echo] 	at org.apache.tools.ant.Task.perform(Task.java:348)
     [echo] 	at org.apache.tools.ant.Target.execute(Target.java:390)
     [echo] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [echo] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [echo] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [echo] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [echo] 	at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [echo] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
     [echo] 	at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
     [echo] Caused by: java.lang.NullPointerException
     [echo] 	at com.liferay.portal.tools.servicebuilder.ServiceBuilder.getMappingEntities(ServiceBuilder.java:1004)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [echo] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [echo] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [echo] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [echo] 	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:866)
     [echo] 	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106)
     [echo] 	... 53 more

</init></init></init></init>

can you post your service.xml??
here some example
<entity name="Parent" local-service="true" remote-service="false">
 
<column name="parentId" type="long" primary="true" />
 <column name="childId" type="Collection" entity="Child" mapping-key="childId" />

 
</entity>
 
 
 
<entity name="Child" local-service="true" remote-service="false">
 
<column name="childId" type="long" primary="true" />
 
<column name="parentId" type="Collections" entity="Parent" mapping-key="parentId" />
 
</entity>

hope this help
Giuseppe Pantaleo, módosítva 11 év-val korábban

RE: Creating many-to-many relationship with existing entites

New Member Bejegyzések: 15 Csatlakozás dátuma: 2012.06.18. Legújabb bejegyzések
I'm experiencing the same problem; have you solved it?
Here is service.xml file:

Mellékletek:

Robson SARAIVA Ximenes, módosítva 11 év-val korábban

RE: Creating many-to-many relationship with existing entites

New Member Bejegyzések: 10 Csatlakozás dátuma: 2012.06.18. Legújabb bejegyzések
Same error on my stack trace;


<!--?xml version="1.0" encoding="UTF-8"?-->

<service-builder package-path="br.catalogo">
	<author></author>
	<namespace>CAT</namespace>
	<entity name="Categoria" local-service="true" remote-service="false">
    	<!-- PK fields -->
		<column name="categoriaId" type="long" primary="true" />
		<!-- Group instance -->
		<column name="groupId" type="long" />
		<!-- Audit fields -->
		<column name="companyId" type="long" />
		<column name="userId" type="long" />
		<column name="userName" type="String" />
		<column name="createDate" type="Date" />
		<column name="modifiedDate" type="Date" />
		
		<!-- Other fields -->
		<column name="nome" type="String" />
		<column name="descricao" type="String" />
		
		<!-- Order -->
		<order by="asc">
			<order-column name="nome" case-sensitive="false" />
		</order>		
    </entity>

	<entity name="Aplicativo" local-service="true" remote-service="false">
		<!-- PK fields -->
		<column name="aplicativoId" type="long" primary="true" />
		<!-- Group instance -->
		<column name="groupId" type="long" />
		<!-- Audit fields -->
		<column name="companyId" type="long" />
		<column name="userId" type="long" />
		<column name="userName" type="String" />
		<column name="createDate" type="Date" />
		<column name="modifiedDate" type="Date" />

		<!-- Other fields -->
		<column name="nome" type="String" />
		<column name="descricao" type="String" />
		
		<!-- Relationships -->
		<column name="categorias" type="Collection" entity="Categoria" mapping-table="aplicativo_categoria" />
		<!-- Fala adicionar: plataformas -->
		
		<!-- Order -->
		<order by="asc">
			<order-column name="nome" case-sensitive="false" />
		</order>		
	</entity>    
</service-builder>



The problem happens because of
<column name="categorias" type="Collection" entity="Categoria" mapping-table="aplicativo_categoria" />

I tried some variations:
<column name="categorias" type="Collection" entity="Categoria" mapping-table="Aplicativo_Categoria" />

<column name="categorias" type="Collection" entity="Categoria" mapping-table="Aplicativos_Categorias" />

<column name="categorias" type="Collection" entity="Categoria" mapping-table="aplicativos_categoria"s />


All with same erro...

Mellékletek:

thumbnail
Cesar Alvarez, módosítva 10 év-val korábban

RE: Creating many-to-many relationship with existing entites

New Member Bejegyzések: 3 Csatlakozás dátuma: 2013.05.19. Legújabb bejegyzések
I was just having the same issue and stumbled upon this thread ... I was able to fix it by actually putting the package name before the entity

<column name="categorias" type="Collection" entity="br.catalogo.Categoria" mapping-table="aplicativo_categoria" />


Not sure why this happens if they're in the same file.
thumbnail
Michele Zanarotti, módosítva 11 év-val korábban

RE: Creating many-to-many relationship with existing entites

Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2012.02.20. Legújabb bejegyzések
Hello. Have you find any solution yet ?

Basically i don't understand if I have to create the relational table by myself, or Liferay will generate a new Table with the given mapping-table name.
sureshnaik ramavath, módosítva 10 év-val korábban

RE: Creating many-to-many relationship with existing entites

New Member Bejegyzések: 18 Csatlakozás dátuma: 2013.06.14. Legújabb bejegyzések
Hi Peter,

liferay source for all service.xml and look for keywords: mapping-key (for one to many) and mapping-table (for many to many) relations.

Example service.xml taken from: \liferay-portal-src-5.0.1\portal-impl\src\com\liferay\portlet\shopping :


<entity name="ShoppingItem" local-service="true" remote-service="true">

<!-- PK fields -->

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

<!-- Audit fields -->

<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />

<!-- Other fields -->

<column name="categoryId" type="long" />
<column name="sku" type="String" />
<column name="name" type="String" />
<column name="description" type="String" />
<column name="properties" type="String" />
<column name="fields" type="boolean" />
<column name="fieldsQuantities" type="String" />
<column name="minQuantity" type="int" />
<column name="maxQuantity" type="int" />
<column name="price" type="double" />
<column name="discount" type="double" />
<column name="taxable" type="boolean" />
<column name="shipping" type="double" />
<column name="useShippingFormula" type="boolean" />
<column name="requiresShipping" type="boolean" />
<column name="stockQuantity" type="int" />
<column name="featured" type="boolean" />
<column name="sale" type="boolean" />
<column name="smallImage" type="boolean" />
<column name="smallImageId" type="long" />
<column name="smallImageURL" type="String" />
<column name="mediumImage" type="boolean" />
<column name="mediumImageId" type="long" />
<column name="mediumImageURL" type="String" />
<column name="largeImage" type="boolean" />
<column name="largeImageId" type="long" />
<column name="largeImageURL" type="String" />

<!-- Relationships -->

<column name="shoppingItemPrices" type="Collection" entity="ShoppingItemPrice" mapping-key="itemId" />

and then you have reference entity ShoppingItemPrice:

<entity name="ShoppingItemPrice" local-service="true" remote-service="false">

<!-- PK fields -->

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

<!-- Other fields -->

<column name="itemId" type="long" />
<column name="minQuantity" type="int" />
<column name="maxQuantity" type="int" />
<column name="price" type="double" />
<column name="discount" type="double" />
<column name="taxable" type="boolean" />
<column name="shipping" type="double" />
<column name="useShippingFormula" type="boolean" />
<column name="status" type="int" />

As I understand this, for me this is one to one relationship, but type="Collection" states that result might contain more than one price for an item. Strange, but that's how they designed it.

In this particular example, considering relation from main table to the second one using itemId which is not PK, it would be wise to add a finder (I am not sure if it's necessary), but finder will help you search items on foreign key, which is here itemId (generated classes has only searching by primary key which is here priceId, and will not help you much). Therefore they also created one finder:
<!-- Finder methods -->

<finder name="ItemId" return-type="Collection">
<finder-column name="itemId" />
</finder>


But, before you dive into this example, I have seen that there are not many relations in liferay table. Instead they use table classname_ that has list of classes.

So for example: in lportal.address table, there is a field classNameId, that is usually 10034 (in my instalation) and stands for com.liferay.portal.model.User and then classPK is the primary key of mentioned table, which means that this is an address of user with id 18206 (in my case). And indeed, user 18206 does exist.

This is not classical relationship, but indeed something that you should be aware of. Search forum for classPK and classNameId to get more inspiration.

Also note that this classes_ table is updated when you use ext environment and that class names are added automatically there, so your entities (tables) will be there.
By using of this code you can get idea.
I shared what I know about this.

Thanks,
Suresh