Foren
Liferay 7 Service Builder, Issue with Primary Key with Date type.
Steve Barski, geändert vor 6 Jahren.
Liferay 7 Service Builder, Issue with Primary Key with Date type.
New Member Beiträge: 4 Beitrittsdatum: 08.01.16 Neueste Beiträge
Has anyone run into issue with service builder and using a Date type in as a part of composite in a Finder method. I have the below service XML and when building the service seems that Liferay 7 is not including the Date type as part of the class import, which causes the build to fail. I do not have an issue building this in Liferay 6.2. I appreciate an insights.
Thanks,
Steve
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.xgjtiv.vp.feedback">
<author>GSB</author>
<namespace>Feedback</namespace>
<entity name="Feedback" table="vp_feedback" local-service="true" remote-service="false">
<!-- PK Fields -->
<column name="organization" db-name="org" primary="true" type="String" />
<column name="userEmailAddress" db-name="user_email" primary="true" type="String" />
<column name="submitDate" db-name="submit_date" primary="true" type="Date" />
<!-- Other Fields -->
<column name="userFirstName" db-name="user_first_name" type="String" />
<column name="userLastName" db-name="user_last_name" type="String" />
<column name="topic" db-name="topic" type="String" />
<column name="feedback" db-name="feedback" type="String" />
<column name="userAgent" db-name="user_agent" type="String" />
<!-- Finders -->
<finder name="vp_feedback_pk" db-index="true" return-type="Collection">
<finder-column name="organization" />
<finder-column name="userEmailAddress" />
<finder-column name="submitDate" />
</finder>
</entity>
</service-builder>
error from the build:
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:74: error: cannot find symbol
[javac] public static final Accessor<Feedback, Date> SUBMIT_DATE_ACCESSOR = new Accessor<Feedback, Date>() {
[javac] ^
[javac] symbol: class Date
[javac] location: interface Feedback
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:74: error: cannot find symbol
[javac] public static final Accessor<Feedback, Date> SUBMIT_DATE_ACCESSOR = new Accessor<Feedback, Date>() {
[javac] ^
[javac] symbol: class Date
[javac] location: interface Feedback
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:76: error: cannot find symbol
[javac] public Date get(Feedback feedback) {
[javac] ^
[javac] symbol: class Date
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:81: error: cannot find symbol
[javac] public Class<Date> getAttributeClass() {
[javac] ^
[javac] symbol: class Date
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:82: error: cannot find symbol
[javac] return Date.class;
[javac] ^
[javac] symbol: class Date
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 5 errors
Thanks,
Steve
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.xgjtiv.vp.feedback">
<author>GSB</author>
<namespace>Feedback</namespace>
<entity name="Feedback" table="vp_feedback" local-service="true" remote-service="false">
<!-- PK Fields -->
<column name="organization" db-name="org" primary="true" type="String" />
<column name="userEmailAddress" db-name="user_email" primary="true" type="String" />
<column name="submitDate" db-name="submit_date" primary="true" type="Date" />
<!-- Other Fields -->
<column name="userFirstName" db-name="user_first_name" type="String" />
<column name="userLastName" db-name="user_last_name" type="String" />
<column name="topic" db-name="topic" type="String" />
<column name="feedback" db-name="feedback" type="String" />
<column name="userAgent" db-name="user_agent" type="String" />
<!-- Finders -->
<finder name="vp_feedback_pk" db-index="true" return-type="Collection">
<finder-column name="organization" />
<finder-column name="userEmailAddress" />
<finder-column name="submitDate" />
</finder>
</entity>
</service-builder>
error from the build:
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:74: error: cannot find symbol
[javac] public static final Accessor<Feedback, Date> SUBMIT_DATE_ACCESSOR = new Accessor<Feedback, Date>() {
[javac] ^
[javac] symbol: class Date
[javac] location: interface Feedback
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:74: error: cannot find symbol
[javac] public static final Accessor<Feedback, Date> SUBMIT_DATE_ACCESSOR = new Accessor<Feedback, Date>() {
[javac] ^
[javac] symbol: class Date
[javac] location: interface Feedback
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:76: error: cannot find symbol
[javac] public Date get(Feedback feedback) {
[javac] ^
[javac] symbol: class Date
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:81: error: cannot find symbol
[javac] public Class<Date> getAttributeClass() {
[javac] ^
[javac] symbol: class Date
[javac] C:\SP14_Code_Convert_v3\liferay-plugins-sdk-6.2-ee-sp14\portlets\vantage-point-feedback-portlet\docroot\WEB-INF\service\com\unisys\vantagepoint\feedback\model\Feedback.java:82: error: cannot find symbol
[javac] return Date.class;
[javac] ^
[javac] symbol: class Date
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 5 errors
David H Nebinger, geändert vor 6 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Looks like it is not handling the import correctly for java.util.Date, that's why you get symbol errors on the class.
Steve Barski, geändert vor 6 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
New Member Beiträge: 4 Beitrittsdatum: 08.01.16 Neueste Beiträge
Correct. The import for java.util.Date statement is not generated in the service classes, which this seems like a bug in Liferay 7. Unless someone has an idea for a work around. Any ideas?
Christoph Rabel, geändert vor 6 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Liferay Legend Beiträge: 1554 Beitrittsdatum: 24.09.09 Neueste Beiträge
Two ideas:
1) Workspace version:
Look into settings.gradle and check your "workspace version". It should be at least 1.5
If it is below "1.5.0", you could try to replace the settings.gradle with above file.
2) Add Date to the Impl class:
FeedbackImpl.java:
Service builder also looks into the implementation and maybe you can "inject" the import "from above".
Btw.: If you have this issue with workspace 1.5.0, you should file a bug.
1) Workspace version:
Look into settings.gradle and check your "workspace version". It should be at least 1.5
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.5.0"
classpath group: "net.saliman", name: "gradle-properties-plugin", version: "1.4.6"
}
repositories {
maven {
url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "net.saliman.properties"
apply plugin: "com.liferay.workspace"
If it is below "1.5.0", you could try to replace the settings.gradle with above file.
2) Add Date to the Impl class:
FeedbackImpl.java:
public Date getDummy() { return null;}
Service builder also looks into the implementation and maybe you can "inject" the import "from above".
Btw.: If you have this issue with workspace 1.5.0, you should file a bug.
Steve Barski, geändert vor 6 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
New Member Beiträge: 4 Beitrittsdatum: 08.01.16 Neueste Beiträge
I have workspace 1.5.0, and tried the suggestion but still not working. Any other ideas? I would like a work around instead of filing a bug report.
Thanks!
Thanks!
Kevin Neibarger, geändert vor 4 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Regular Member Beiträge: 105 Beitrittsdatum: 02.02.18 Neueste BeiträgeI realize this is an old post, but I've downloaded the most current liferay 7.2 bundle and any service builder entity that has a composite PK generates the appropriate classes but those classes don't compile. Below is my gradle file
buildscript {dependencies {classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "3.9.10"}
repositories {maven {url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"}}}
subprojects {apply plugin: "com.liferay.plugin"
repositories {mavenLocal()
maven {url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"}}}
I get compile errors that the constructor's don't exist. Am I using the incorrect version of the com.liferay.gradle.plugins?
David H Nebinger, geändert vor 4 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
I just ran into something like this the other day. Turned out the default build.gradle for the -api module was missing some new dependencies:
Once I added those last two dependencies in, all was fine. I'm using the target platform support, so I don't have to list the versions explicitly.
dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.0"
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
}
Once I added those last two dependencies in, all was fine. I'm using the target platform support, so I don't have to list the versions explicitly.
Kevin Neibarger, geändert vor 4 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Regular Member Beiträge: 105 Beitrittsdatum: 02.02.18 Neueste Beiträge
I did find a correct configuration for the Gradle file, but the problem that remains seems to be an issue with java.util.Date when the build service builds the service and api classes. For example, I have an entity with a composite key
It appears that dateAdded is being treated as a long when the xxxPK class is being called and that xxxPK class is passing a long where a java.util.Date should be.
interventionAgingReportCarePlanPK = new InterventionAgingReportCarePlanPK(upi,practice, category, subCategory, detail, dateAdded);
So the above gives a compile error. Seems to be a bug with the service builder, as it's not correctly reading a java.util.Date for some reason. Has this implementation changed so we now can't use a java.util.Date in a composite key now??
<column name="upi" db-name="UPI" type="int" primary="true" />
<column name="category" type="String" primary="true" /><column name="subCategory" type="String" primary="true" /><column name="detail" type="String" primary="true" />
<column name="dateAdded" type="Date" primary="true" />
It appears that dateAdded is being treated as a long when the xxxPK class is being called and that xxxPK class is passing a long where a java.util.Date should be.
interventionAgingReportCarePlanPK = new InterventionAgingReportCarePlanPK(upi,practice, category, subCategory, detail, dateAdded);
So the above gives a compile error. Seems to be a bug with the service builder, as it's not correctly reading a java.util.Date for some reason. Has this implementation changed so we now can't use a java.util.Date in a composite key now??
Kevin Neibarger, geändert vor 4 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Regular Member Beiträge: 105 Beitrittsdatum: 02.02.18 Neueste Beiträge
After some configuration changes and setting the com.liferay.gradle.plugins to 3.12.74 I'm getting the following error when trying to build the service classes
Why is java.util.Date no longer supported in Liferay 7.1?? It was supported in 6.2 as I had no issues with it... This makes little sense to downgrade support in newer versions... Anyone know what java.util.Date is not supported?
service.api.dir=${basedir}/../portal-kernel/srcservice.auto.import.default.references=trueException in thread "main" service.auto.namespace.tables=falseservice.bean.locator.util=com.liferay.portal.kernel.bean.PortalBeanLocatorUtilservice.build.number=1service.build.number.increment=trueservice.hbm.file=${basedir}/src/META-INF/portal-hbm.xmlservice.impl.dir=${basedir}/srcservice.input.file=${service.file}service.model.hints.configs=classpath*:META-INF/portal-model-hints.xml,META-INF/portal-model-hints.xml,classpath*:META-INF/ext-model-hints.xml,classpath*:META-INF/portlet-model-hints.xmlservice.model.hints.file=${basedir}/src/META-INF/portal-model-hints.xmlservice.osgi.module=falseservice.plugin.name=service.props.util=
com.liferay.portal.util.PropsUtiljava.lang.IllegalArgumentException: Primary key dateAdded of entity InterventionAgingReportEngine must be an int, long, or String
service.read.only.prefixes=fetch,get,has,is,load,reindex,searchservice.resource.actions.configs=META-INF/resource-actions/default.xml,resource-actions/default.xml
Why is java.util.Date no longer supported in Liferay 7.1?? It was supported in 6.2 as I had no issues with it... This makes little sense to downgrade support in newer versions... Anyone know what java.util.Date is not supported?
David Truong, geändert vor 4 Jahren.
RE: Liferay 7 Service Builder, Issue with Primary Key with Date type.
Expert Beiträge: 322 Beitrittsdatum: 24.03.05 Neueste Beiträge
It was killed because we discovered that in different scenarios (different OS/JVM/D combinations because of precision issues you would not get the same results. We recommend converting it to a long timestamp instead.