Hi,
> As you see the columnDefinition is taken instead of column name (the SQL
> will be correct if I delete columnDefinition for this column).
>
> Has somebody some ideas how to fix SQL without removing of columnDefinition?
If you remove the columnDefinition, does the problem go away? I'm not
suggesting that as a solution, but the answer will help debug the
problem.
Thanks,
-Patrick
On 10/3/07, AlexD. <[EMAIL PROTECTED]> wrote:
>
> Hallo,
>
>
> It looks like SQL is wrong generated when I'm using relation annotations in
> my class plus runtime lazy loading:
>
> @Entity
> @Table(name = "lkp_dys_days")
> @NamedQueries( { @NamedQuery(name = "getDay", query = "select x from Days x
> where x.dysYear = ?1 and x.dysMonth = ?2 and x.dysDay = ?3") })
> public class Days {
> ...
> @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
> @JoinColumn(name="DMN_DOMAIN_ID", columnDefinition="int unsigned",
> nullable=false)
> private Domain domain;
> ...
> }
>
> the result sql is:
>
> SELECT t0.DYS_DAY_ID, t0.int unsigned, t0.DYS_BT_FICAL_QUARTER,
> t0.DYS_BT_FISCAL_YEAR, t0.DYS_BT_SEMESTER, t0.DYS_DATE, t0.DYS_DAY,
> t0.DYS_DAY_CODE_DE, t0.DYS_DAY_CODE_EN, t0.DYS_DAY_NAME, t0.DYS_IS_WEEKEND,
> t0.DYS_MONTH, t0.DYS_MONTH_CODE_DE, t0.DYS_MONTH_CODE_EN, t0.DYS_MONTH_NAME,
> t0.DYS_QUARTER, t0.DYS_QUARTER_NAME, t0.DYS_WEEK, t0.DYS_YEAR FROM
> lkp_dys_days t0 WHERE (t0.DYS_YEAR = ? AND t0.DYS_MONTH = ? AND t0.DYS_DAY =
> ?) [params=(int) 2007, (int) 1, (int) 1]
>
> As you see the columnDefinition is taken instead of column name (the SQL
> will be correct if I delete columnDefinition for this column).
>
> Has somebody some ideas how to fix SQL without removing of columnDefinition?
>
> Some more information: this is a code what I'm using:
>
> ...
> final Properties p = new Properties();
> p.put("openjpa.ConnectionDriverName", "com.mysql.jdbc.Driver");
> p.put("openjpa.ConnectionURL", "jdbc:mysql://localhost:3306/xyz");
> p.put("openjpa.ConnectionUserName", "xyz");
> p.put("openjpa.ConnectionPassword", "xyz");
> p.put("openjpa.jdbc.DBDictionary",
> "org.apache.openjpa.jdbc.sql.MySQLDictionary");
> p.put("openjpa.Log", "DefaultLevel=TRACE,SQL=TRACE");
>
> final EntityManagerFactory factory =
> Persistence.createEntityManagerFactory("relations", p);
> final EntityManager em = factory.createEntityManager();
>
> final Query q = em.createNamedQuery("getDay");
> q.setParameter(1, year);
> q.setParameter(2, month);
> q.setParameter(3, day);
> final List dl = q.getResultList();
> Days d = null;
> if (dl != null && dl.size() > 0) {
> d = dl.iterator().next();
> }
> ....
>
>
> thanks in advice,
>
> alex
> --
> View this message in context:
> http://www.nabble.com/wrong-sql-for-tables-relation-tf4565246.html#a13030884
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
--
Patrick Linskey
202 669 5907