You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Dimedrol <di...@mailinator.com> on 2010/04/22 00:03:01 UTC

MySQL openjpa.MetaData doesn't resolve one field

Hello!
I use Intellij IDEA 95.24; OpenJPA 1.2.2 and MySQL 5 database.

All java entities - mapped to mysql tables were created by IDEA wizard.
Everything was OK, but I have met 1 strange problem:

In one of my MySQL tables:
-------------------
CREATE TABLE kl_mytable (
  id_klmytable int(11) NOT NULL auto_increment,
  name char(100) NOT NULL,
  n_link int(11) NOT NULL,
  id_country int(11) NOT NULL,
  PRIMARY KEY  (id_klmytable),
  KEY id_country (id_country),
  CONSTRAINT kl_mytable_fk FOREIGN KEY (id_country) REFERENCES country
(id_country)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
-------------------

there is a problem with the field "n_link".



IDEA has generated a proper entity mapping:

+++++++++++++++
    private Integer nLink;

    @javax.persistence.Column(name = "n_link")
    @Basic
    public Integer getnLink() {
        return nLink;
    }

    public void setnLink(Integer nLink) {
        this.nLink = nLink;
    }
+++++++++++++++



But in the logs I see:

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

23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData -
Initializing mapping for "server.domain.KlMytable@28318025".
23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
Resolving field "server.domain.KlMytable@28318025.countryByIdCountry".
23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
Resolving field "server.domain.KlMytable@28318025.idKlmytable".
23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
Resolving field "server.domain.KlMytable@28318025.name".
23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
Resolving field "server.domain.KlMytable@28318025.remotedataByIdKlmytable".

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

It means, OpenJPA does not resolves this field "n_link" and in the Query it
always returns NULL as its value.

When I try do debug a little deeper, I also see - "no field named" exception
about this "n_link" field,
but IDEA sees this field and even helps me to create the Query with code
completion, using this "absent" (like OpenJPA thinks) field.


So, please, help. 
What am I doing wrong?



-- 
View this message in context: http://n2.nabble.com/MySQL-openjpa-MetaData-doesn-t-resolve-one-field-tp4939712p4939712.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: MySQL openjpa.MetaData doesn't resolve one field

Posted by Dimedrol <di...@mailinator.com>.
Guys, I have solved this problem!!!
This is a naming issue!

I have just renamed my GETter ant SETter, using Java beans naming convention
and
everything is OK now!

New correct naming:

public Integer getNlink()...
and 
public void setNlink(Integer nLink)...

Capital letter right after "get/set".

Why IDEA hasn't create correct naming?... 

So, it's a question for JetBrains team ;-)
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/MySQL-openjpa-MetaData-doesn-t-resolve-one-field-tp4939712p4959469.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: MySQL openjpa.MetaData doesn't resolve one field

Posted by Donald Woods <dw...@apache.org>.
Why is n_link be expressed as "int(11)"?
Is this how IDEA displays it?

I was expecting something like -
    n_link INTEGER NOT NULL,


-Donald


On 4/21/10 6:03 PM, Dimedrol wrote:
> 
> Hello!
> I use Intellij IDEA 95.24; OpenJPA 1.2.2 and MySQL 5 database.
> 
> All java entities - mapped to mysql tables were created by IDEA wizard.
> Everything was OK, but I have met 1 strange problem:
> 
> In one of my MySQL tables:
> -------------------
> CREATE TABLE kl_mytable (
>   id_klmytable int(11) NOT NULL auto_increment,
>   name char(100) NOT NULL,
>   n_link int(11) NOT NULL,
>   id_country int(11) NOT NULL,
>   PRIMARY KEY  (id_klmytable),
>   KEY id_country (id_country),
>   CONSTRAINT kl_mytable_fk FOREIGN KEY (id_country) REFERENCES country
> (id_country)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
> -------------------
> 
> there is a problem with the field "n_link".
> 
> 
> 
> IDEA has generated a proper entity mapping:
> 
> +++++++++++++++
>     private Integer nLink;
> 
>     @javax.persistence.Column(name = "n_link")
>     @Basic
>     public Integer getnLink() {
>         return nLink;
>     }
> 
>     public void setnLink(Integer nLink) {
>         this.nLink = nLink;
>     }
> +++++++++++++++
> 
> 
> 
> But in the logs I see:
> 
> ===============
> 
> 23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData -
> Initializing mapping for "server.domain.KlMytable@28318025".
> 23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
> Resolving field "server.domain.KlMytable@28318025.countryByIdCountry".
> 23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
> Resolving field "server.domain.KlMytable@28318025.idKlmytable".
> 23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
> Resolving field "server.domain.KlMytable@28318025.name".
> 23797  NewPersistenceUnit  TRACE  [http-8080-Processor25] openjpa.MetaData - 
> Resolving field "server.domain.KlMytable@28318025.remotedataByIdKlmytable".
> 
> ===============
> 
> It means, OpenJPA does not resolves this field "n_link" and in the Query it
> always returns NULL as its value.
> 
> When I try do debug a little deeper, I also see - "no field named" exception
> about this "n_link" field,
> but IDEA sees this field and even helps me to create the Query with code
> completion, using this "absent" (like OpenJPA thinks) field.
> 
> 
> So, please, help. 
> What am I doing wrong?
> 
> 
>