[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-4117) Seam-gen generate EntityList with RESTRICTIONS which do not work for other JPA providers
Julien Kronegg (JIRA)
jira-events at lists.jboss.org
Tue Apr 14 10:03:22 EDT 2009
[ https://jira.jboss.org/jira/browse/JBSEAM-4117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julien Kronegg updated JBSEAM-4117:
-----------------------------------
Workaround Description: The user can implement this patch itself as EntityList.java.ftl is available.
Environment: OpenJPA 1.2.1, Seam 2.1.2-SNAPSHOT
Original Estimate: 4 hours
Remaining Estimate: 4 hours
Affects Version/s: 2.1.1.GA
2.0.0.GA
2.1.2.CR1
Description:
Each EntityList generated by Seam-gen contains RESTRICTIONS like the following one:
"lower(myEntity.myField) like lower(concat(#{myEntityList.myEntity.myField}, '%'))"
While this works fine under Hibernate, other JPA providers may not support this syntax as it is not described in the JPA specifications (1.0 and 2.0): the right hand side of the "LIKE" term must be a String, not a function. For OpenJPA, this problem is described in the following JIRA issue: https://issues.apache.org/jira/browse/OPENJPA-920
Solution:
In order to make Seam-gen's entityLists supported by other JPA providers, we could add a new Seam component JpaProviderUtils
@Name("jpaProviderUtils") {
public class JpaProviderUtils {
public String getLikeParameter(String likeParameter) {
return (likeParameter!=null?likeParameter.toLowerCase()+'%':null);
}
}
Then seam-gen must be modified to produce RESTRICTIONS such as:
"lower(myEntity.myField) like #{jpaProviderUtils.getLikeParameter(myEntityList.myEntity.myField)}"
This is done simply by updating the seam-gen/src/EntityList.java.ftl (from Seam 2.1.2-SNAPSHOT):
-line 26 : "lower(${componentName}.${property.name}.${componentProperty.name}) like lower(concat(${'#'}{${listName}.${property.name}.${componentProperty.name}}, '%'))",
+line 26 : "lower(${componentName}.${property.name}.${componentProperty.name}) like ${'#'}{jpaProviderUtils.getLikeParameter(${listName}.${property.name}.${componentProperty.name})}",
-line 31: "lower(${componentName}.${property.name}) like lower(concat(${'#'}{${listName}.${property.name}}, '%'))",
+line 31: "lower(${componentName}.${property.name}) like ${'#'}{jpaProviderUtils.getLikeParameter(${listName}.${property.name})}",
was:
Each EntityList generated by Seam-gen contains RESTRICTIONS like:
"lower(myEntity.myField) like lower(concat(#{myEntityList.myEntity.myField, '%'))"
Workaround: [Workaround Exists]
> Seam-gen generate EntityList with RESTRICTIONS which do not work for other JPA providers
> ----------------------------------------------------------------------------------------
>
> Key: JBSEAM-4117
> URL: https://jira.jboss.org/jira/browse/JBSEAM-4117
> Project: Seam
> Issue Type: Bug
> Components: Tools
> Affects Versions: 2.0.0.GA, 2.1.1.GA, 2.1.2.CR1
> Environment: OpenJPA 1.2.1, Seam 2.1.2-SNAPSHOT
> Reporter: Julien Kronegg
> Original Estimate: 4 hours
> Remaining Estimate: 4 hours
>
> Each EntityList generated by Seam-gen contains RESTRICTIONS like the following one:
> "lower(myEntity.myField) like lower(concat(#{myEntityList.myEntity.myField}, '%'))"
> While this works fine under Hibernate, other JPA providers may not support this syntax as it is not described in the JPA specifications (1.0 and 2.0): the right hand side of the "LIKE" term must be a String, not a function. For OpenJPA, this problem is described in the following JIRA issue: https://issues.apache.org/jira/browse/OPENJPA-920
> Solution:
> In order to make Seam-gen's entityLists supported by other JPA providers, we could add a new Seam component JpaProviderUtils
> @Name("jpaProviderUtils") {
> public class JpaProviderUtils {
> public String getLikeParameter(String likeParameter) {
> return (likeParameter!=null?likeParameter.toLowerCase()+'%':null);
> }
> }
> Then seam-gen must be modified to produce RESTRICTIONS such as:
> "lower(myEntity.myField) like #{jpaProviderUtils.getLikeParameter(myEntityList.myEntity.myField)}"
> This is done simply by updating the seam-gen/src/EntityList.java.ftl (from Seam 2.1.2-SNAPSHOT):
> -line 26 : "lower(${componentName}.${property.name}.${componentProperty.name}) like lower(concat(${'#'}{${listName}.${property.name}.${componentProperty.name}}, '%'))",
> +line 26 : "lower(${componentName}.${property.name}.${componentProperty.name}) like ${'#'}{jpaProviderUtils.getLikeParameter(${listName}.${property.name}.${componentProperty.name})}",
> -line 31: "lower(${componentName}.${property.name}) like lower(concat(${'#'}{${listName}.${property.name}}, '%'))",
> +line 31: "lower(${componentName}.${property.name}) like ${'#'}{jpaProviderUtils.getLikeParameter(${listName}.${property.name})}",
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list