Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358179

Summary: Project can NOT be generated when use 'get' to do sql operation
Product: z_Archived Reporter: Yu Hao <yuhaodl>
Component: EDTAssignee: Project Inbox <edt.ide.ui-inbox>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: chenzhh, jvincens, pharmon, tww, yuhaodl, zhuzhi
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Yu Hao CLA 2011-09-20 02:17:00 EDT
Build Identifier: 

Use 'get' to do a SQL operation then there is en error for "The project was not generated because an unexpected error was reported by the EDT builder."

Reproducible: Always

Steps to Reproduce:
1.Create a basic project and only check Java Generator
2.Create a program as below:

package home;

program mypro type BasicProgram {}
	
	rec rec;
	
	function main()
		get rec;
	end
	
end

// basic record
//
record rec
	
	itemName string;
	itemid	int;
end


3.Save the file, there will be two errors:

Description	Resource	Path	Location	Type
Problems occurred during build. Please see log for details.	demo		Unknown	EDT Build Problem
The project was not generated because an unexpected error was reported by the EDT builder.	demo		Unknown	EDT Generation Problem
Comment 1 Paul Harmon CLA 2011-09-20 11:02:51 EDT
I cannot recreate the compile failure...this may be due to something else that was fixed. Reopen the defect if you can recreate, an please provide the contents of the .log file.
Comment 2 Joseph Vincens CLA 2011-09-20 14:25:47 EDT
The code listed below will cause a NPE in org.eclipse.edt.mof.eglx.persistence.sql.impl.SqlGetByKeyStatementImpl.generateDefaultSqlString because it's missing a from/to clause. 
Right now there is no SQL validadtion. I believe Paul has just started working on it, until he completes it you may see generator errors instead of validation errors.

Once I added a from it generated and ran.
Comment 3 Zhi Zhu CLA 2011-09-20 20:44:59 EDT
From the spec, 
   get rec;

is a valid GET action.
Comment 4 Yu Hao CLA 2011-09-20 21:21:42 EDT
Paul and Joe, I used p2 installation to execute the test. Whether you also verified this issue with the p2 plug-in env.?
This morning I updated the latest version of the p2 plug-in and updated my code by your comments as below:
=================
package aaa;

// basic program
//
program bbb type BasicProgram {}
	
	ds SQLDataSource = new SQLDataSource("jdbc:derby:C:/databases/EGLDerbyR7;create=true");
	rec rec;
		
	function main()
		get rec from ds;
	end
	
end


// basic record
//
record rec
	
	itemName string;
	id	int {@id};
end

======================

But the compiler error is still there. I attached the error log here for your reference. BTW. just as ZZ said, SQL spec document declared "get rec" is a valid GET action. You can find the Syntax in page32:
Get_statement ::=
	get action_targets[ from  data_source_exp]r [using_clause]  [with_clause];

the from is in '[]', so it should be an optional parameter.


The error log:

org.eclipse.edt.compiler.internal.core.builder.BuildException: java.lang.RuntimeException: org.eclipse.edt.mof.serialization.TypeNotFoundException: org.eclipse.edt.mof.serialization.MofObjectNotFoundException: MofObject not found: org.eclipse.edt.mof.eglx.persistence.sql.SqlGetByKeyStatement
	at org.eclipse.edt.compiler.internal.core.builder.AbstractProcessingQueue.process(AbstractProcessingQueue.java:187)
	at org.eclipse.edt.compiler.internal.core.builder.AbstractProcessingQueue.process(AbstractProcessingQueue.java:152)
	at org.eclipse.edt.ide.core.internal.builder.AbstractBuilder.processParts(AbstractBuilder.java:99)
	at org.eclipse.edt.ide.core.internal.builder.AbstractBuilder.build(AbstractBuilder.java:136)
	at org.eclipse.edt.ide.core.internal.builder.Builder.cleanBuild(Builder.java:167)
	at org.eclipse.edt.ide.core.internal.builder.Builder.build(Builder.java:94)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.RuntimeException: org.eclipse.edt.mof.serialization.TypeNotFoundException: org.eclipse.edt.mof.serialization.MofObjectNotFoundException: MofObject not found: org.eclipse.edt.mof.eglx.persistence.sql.SqlGetByKeyStatement
	at org.eclipse.edt.mof.impl.EFactoryImpl.getTypeNamed(EFactoryImpl.java:66)
	at org.eclipse.edt.mof.eglx.persistence.sql.impl.SqlFactoryImpl.getSqlGetByKeyStatementEClass(SqlFactoryImpl.java:57)
	at org.eclipse.edt.mof.eglx.persistence.sql.impl.SqlFactoryImpl.createSqlGetByKeyStatement(SqlFactoryImpl.java:119)
	at org.eclipse.edt.compiler.internal.egl2mof.eglx.persistence.sql.SQLActionStatementGenerator.visit(SQLActionStatementGenerator.java:172)
	at org.eclipse.edt.compiler.core.ast.GetByKeyStatement.accept(GetByKeyStatement.java:64)
	at org.eclipse.edt.compiler.internal.egl2mof.AbstractIOStatementGenerator.genGetByKeyStatement(AbstractIOStatementGenerator.java:117)
	at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofStatement.visit(Egl2MofStatement.java:491)
	at org.eclipse.edt.compiler.core.ast.GetByKeyStatement.accept(GetByKeyStatement.java:64)
	at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.handleEndVisitPart(Egl2MofPart.java:521)
	at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.defaultHandleVisitPart(Egl2MofPart.java:386)
	at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.visit(Egl2MofPart.java:169)
	at org.eclipse.edt.compiler.core.ast.Program.accept(Program.java:69)
	at org.eclipse.edt.compiler.internal.egl2mof.Egl2Mof.convert(Egl2Mof.java:160)
	at org.eclipse.edt.ide.core.internal.builder.AbstractProcessingQueue.createIRFromBoundAST(AbstractProcessingQueue.java:245)
	at org.eclipse.edt.ide.core.internal.builder.AbstractProcessingQueue.processCompiledPart(AbstractProcessingQueue.java:221)
	at org.eclipse.edt.ide.core.internal.builder.AbstractProcessingQueue.level03Compile(AbstractProcessingQueue.java:164)
	at org.eclipse.edt.compiler.internal.core.builder.AbstractProcessingQueue.process(AbstractProcessingQueue.java:169)
	... 17 more
Caused by: org.eclipse.edt.mof.serialization.TypeNotFoundException: org.eclipse.edt.mof.serialization.MofObjectNotFoundException: MofObject not found: org.eclipse.edt.mof.eglx.persistence.sql.SqlGetByKeyStatement
	at org.eclipse.edt.mof.serialization.Environment.findType(Environment.java:58)
	at org.eclipse.edt.mof.impl.EFactoryImpl.getTypeNamed(EFactoryImpl.java:64)
	... 33 more
Caused by: org.eclipse.edt.mof.serialization.MofObjectNotFoundException: MofObject not found: org.eclipse.edt.mof.eglx.persistence.sql.SqlGetByKeyStatement
	at org.eclipse.edt.mof.serialization.AbstractEnvironment.find(AbstractEnvironment.java:124)
	at org.eclipse.edt.mof.serialization.AbstractEnvironment.find(AbstractEnvironment.java:100)
	at org.eclipse.edt.mof.serialization.Environment.findType(Environment.java:56)
	... 34 more
Comment 5 Yu Hao CLA 2011-09-20 21:52:00 EDT
I tried the other SQL operations: add, delete, replace, open. They all fired the same error with 'Get'
Comment 6 Tony Chen CLA 2011-09-20 22:31:10 EDT
Would it be possible some of the code are not in the nightly build?
Comment 7 Joseph Vincens CLA 2011-09-21 09:49:27 EDT
If you look at page 38 semantic validations the 2nd bullet says: "If no FROM clause is specified the WITH clause must be specified and must be referencing an expression of type SQLStatement.  In other words if a prepared statement is available there is no need for referencing the explicit datasource"

So you need either a FROM or WITH. If you use a WITH it must be an SQLStatement which uses PREPARE and prepare requires a FROM. 

From what I read a bare GET is not supported. Is there an example in the spec that shows a get with no FROM or WITH?

I did find an error in the spec. On page 13 it shows
    sqlStmt SQLStatement;
it should have a ?
    sqlStmt SQLStatement?;
Comment 8 Joseph Vincens CLA 2011-09-21 15:18:12 EDT
The code was in the build but in the wrong format. The compiler plugin loads
the egllib/sql.mofar file from the org.eclipse.edt.mof.eglx.persistence.sql
plugin, but the plugin was installed as a jar, so the mofar could not be loaded
and that caused a TypeNotFoundException.
I have updated the project to unpack the plugin so it gets installed as a
folder structure not a jar. We ran a build and I verified the problem is fixed.
Comment 9 Yu Hao CLA 2011-09-30 01:41:27 EDT
verified