[ 
https://issues.apache.org/jira/browse/OFBIZ-10645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16682367#comment-16682367
 ] 

Aditya Sharma commented on OFBIZ-10645:
---------------------------------------

I am adding 2 solution patches:

Added check in buildEntity() method of ModelReader class to return null if the 
name is missing and handled it in getEntityCache() method.

Added check in EntityMaint.groovy to skip entity with entity name missing.
 # When entity-name and table-name both are empty, the entity will not be 
processed. In buildEntity(), UtilXml.checkEmpty() method was used which ensured 
that empty string is assigned to the entity name if it is null/empty. It must 
have been done intentionally to fulfil some use case.
 # When entity-name is empty, the entity will not be processed.

> Empty entity name should not be allowed in entity definition
> ------------------------------------------------------------
>
>                 Key: OFBIZ-10645
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10645
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk, Release Branch 16.11, Release Branch 17.12
>            Reporter: Ashish Kumar Pandey
>            Assignee: Aditya Sharma
>            Priority: Trivial
>         Attachments: EntityMaintError.png, OFBIZ-10645-alternate.patch, 
> OFBIZ-10645.patch
>
>
> Present system allows empty name in entity definition due to which there 
> SQLException in console log and error on Entity Mantainence page.
> {code:java}
> 2018-11-10 14:43:45,522 |OFBiz-batch-3        |DatabaseUtil                  
> |I| Error getting primary key info from database with null tableName, will 
> try other means: java.sql.SQLException: Table name can not be null
> 2018-11-10 14:43:45,522 |OFBiz-batch-1        |DatabaseUtil                  
> |I| Error getting primary key info from database with null tableName, will 
> try other means: java.sql.SQLException: Table name can not be null
> 2018-11-10 14:43:45,522 |OFBiz-batch-2        |DatabaseUtil                  
> |I| Error getting primary key info from database with null tableName, will 
> try other means: java.sql.SQLException: Table name can not be null
> 2018-11-10 14:44:06,198 |OFBiz-batch-2        |DatabaseUtil                  
> |W| Entity [] has no table in the database
> 2018-11-10 14:44:06,243 |pool-3-thread-1      |DatabaseUtil                  
> |E| SQL Exception while executing the following:
> CREATE TABLE OFBIZ. (TEST_ID VARCHAR(20) NOT NULL, LAST_UPDATED_STAMP 
> TIMESTAMP, LAST_UPDATED_TX_STAMP TIMESTAMP, CREATED_STAMP TIMESTAMP, 
> CREATED_TX_STAMP TIMESTAMP,  PRIMARY KEY (TEST_ID))
> Error was: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at 
> line 1, column 21.
> java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at line 1, 
> column 21.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) 
> ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.executeLargeUpdate(Unknown Source) 
> ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
>  ~[commons-dbcp2-2.1.1.jar:2.1.1]
>         at 
> org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
>  ~[commons-dbcp2-2.1.1.jar:2.1.1]
>         at 
> org.apache.ofbiz.entity.jdbc.DatabaseUtil.createTable(DatabaseUtil.java:1677) 
> [ofbiz.jar:?]
>         at 
> org.apache.ofbiz.entity.jdbc.DatabaseUtil$CreateTableCallable.call(DatabaseUtil.java:1516)
>  [ofbiz.jar:?]
>         at 
> org.apache.ofbiz.entity.jdbc.DatabaseUtil$CreateTableCallable.call(DatabaseUtil.java:1502)
>  [ofbiz.jar:?]
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
> [?:1.8.0_66]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  [?:1.8.0_66]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  [?:1.8.0_66]
>         at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]
> Caused by: org.apache.derby.iapi.error.StandardException: Syntax error: 
> Encountered "(" at line 1, column 21.
>         at org.apache.derby.iapi.error.StandardException.newException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.iapi.error.StandardException.newException(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.sql.compile.ParserImpl.parseStatementOrSearchCondition(Unknown
>  Source) ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source) 
> ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown 
> Source) ~[derby-10.14.1.0.jar:?]
>         at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) 
> ~[derby-10.14.1.0.jar:?]
>         at 
> org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
>  Source) ~[derby-10.14.1.0.jar:?]
>         ... 12 more
> 2018-11-10 14:44:06,259 |pool-3-thread-1      |DatabaseUtil                  
> |E| Could not create table [OFBIZ.]: SQL Exception while executing the 
> following:
> CREATE TABLE OFBIZ. (TEST_ID VARCHAR(20) NOT NULL, LAST_UPDATED_STAMP 
> TIMESTAMP, LAST_UPDATED_TX_STAMP TIMESTAMP, CREATED_STAMP TIMESTAMP, 
> CREATED_TX_STAMP TIMESTAMP,  PRIMARY KEY (TEST_ID))
> Error was: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at 
> line 1, column 21.{code}
> !EntityMaintError.png!  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to