I'm starting on a new project, and I've been told the usual "download everything and build it" task. The project spans across different eclipse projects, all of them using maven for dependency management, and, up until this specific project, the "import SVN project to eclipse -> right click -> configure -> convert to maven project" has worked just fine.
The problem comes with this project. It seems it uses JPA for database access (There are several entity classes with annotated @NamedQuery elements), but, somehow, eclipse is reporting that some of those queries are erroneous ("A select statement must have a FROM clause" and "The expression is invalid, which means it does not follow the JPQL grammar" are the most repeated errors).
So this is an example of the code that gives the errors:
@javax.persistence.Entity
@Table(name = "TABLE_NAME")
@NamedQueries({
@NamedQuery(name = UserEntity.ALL, query = "select u from UserEntity u"),
@NamedQuery(name = UserEntity.ALL_PAGINATION, query = "select u from UserEntity u ORDER BY lower(u.alias)"),
@NamedQuery(name = UserEntity.ALL_FILTER_PAGINATION, query = "select u from UserEntity u where u.alias LIKE lower(:query) OR u.email LIKE lower(:query) OR lower(u.documentNumber) LIKE lower(:query) ORDER BY u.alias"),
@NamedQuery(name = UserEntity.COUNT_ALL, query = "select count(u) from UserEntity u") })
Here, it complains about the third line ("lower(u.alias)" is marked, and "lower(:query) on the three times it appears in the fourht line. All those errors are marked with a "The expression is invalid, which means it does not follow the JPQL grammar". I can provide if needed more errors I'm getting.
The thing is that I'm the only one who is getting this errors. The other dev on my team got his stuff time ago and his project does not fail, which makes me think it has something to do with dependencies.
The pom.xml file for the project reads as this:
<!-- JPA -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</dependency>
I searched in our nexus server and changed the javax.persistence to the specific code for the last version to no avail:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
The other dev has no idea of what's going on and I haven't used JPA in my life, but I have a strong feeling that my problem does not have to do anything with the actual syntax. I've tried more times that I remember re-downloading everything and re-maven/update it. The project can't be wrong, as it was uploaded 2 years ago and haven't been touched since (Or so it seems), so it must be something related to dependencies or configuration, but I have no clue on where to move now.
What I'm missing here?
EDIT: Ok, this code (let's call it ProjectDep) was a dependency to ProjectA. I asked the other dev for the .jar file for this code's project, to see if it worked, and it works just fine (After closing my version of ProjectDep).
This is one of the error lines from the SVN code:
@javax.persistence.Entity
@Table(name = "TABLE_NAME_WHATEVER")
@NamedQueries({
@NamedQuery(name = FormNameEntity.ALL, query = "select ns from FormNameEntity ns"),
@NamedQuery(name = FormNameEntity.BY_FLOW_ID, query = "select ns from FormNameEntity ns where formFlowId = :formFlowId") })
And this is the same line from the jar file, after passing through Java Decompiler:
@javax.persistence.Entity
@Table(name="TABLE_NAME_WHATEVER")
@NamedQueries({@javax.persistence.NamedQuery(name="all", query="select ns from FormNameEntity ns"), @javax.persistence.NamedQuery(name="byFlowId", query="select ns from FormNameEntity ns where formFlowId = :formFlowId")})
They are quite different, and it seems that there are more differences on the jar file. Still, this is no reason for why the error messages appear.
Well, I managed to solve the issue.
Turns out, the errors are a known bug in Kepler which can be solved just by disabling the JPA validation (And it seems its a bug already fixed on newer versions of whatever makes the validation) and re-downloading the project from the SVN.
Seems my coworked had the validation disabled from the beginning and he didn't remember when he disabled it. Oh, well...