users@glassfish.java.net

Re: [JPA] Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:

From: Allan Lykke Christensen <allan_at_i2m.dk>
Date: Mon, 7 Mar 2011 14:38:20 +0100

Hi there,

EM is the EntityManager that you've added to the entity. The
EntityManager shouldn't be in the entity itself. If you need to have
it there, for what ever reason, try annotating it as @Transient

Regards,
  Allan

On 07/03/2011, at 14.33, Sreekanth wrote:

> Hi,
>
> I have a MySQL table(Users) like:
>
> ID INT
> USER_ID VARCHAR
> PASSWORD VARCHAR
> FIRST_NAME VARCHAR
> LAST_NAME VARCHAR
> CREATED_BY INT
> CREATED_TIME DATETIME
> LEVEL_ID SMALLINT
>
> and a entity class auto created by eclipse (See attached file.)
>
> Now when I execute the method loginUser() which in turn tries to
> execute the named query :
>
> @NamedQuery(name = "User.findByUserId", query = "SELECT u FROM User
> u WHERE u.userId = :userId"),
>
>
> javax.servlet.ServletException: Exception [EclipseLink-4002]
> (Eclipse Persistence Services - 2.2.0.v20110202-r8913):
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception:
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown
> column 'EM' in 'field list'
> Error Code: 1054
> Call: SELECT ID, CREATED_BY, CREATED_TIME, EM, FIRST_NAME,
> LAST_NAME, PASSWORD, USER_ID, LEVEL_ID FROM USERS WHERE (USER_ID = ?)
> bind => [1 parameter bound]
> Query: ReadAllQuery(name="User.findByUserId" referenceClass=User
> sql="SELECT ID, CREATED_BY, CREATED_TIME, EM, FIRST_NAME, LAST_NAME,
> PASSWORD, USER_ID, LEVEL_ID FROM USERS WHERE (USER_ID = ?)")
>
> Why is the column EM created? I am using latest glassfish and MySQL
> Database.Please help.
>
>
>
> Thanks,
> Sreekanth
>
>
>
> <User.java><server.log>