java - JPA/Metamodel: Strange (inconsistent ?) example in Sun Docs -


in sun online resources, provide son example usage of criteria/metamodel api, far understand java, seems impossible work:

criteriaquery<pet> cq = cb.createquery(pet.class); metamodel m = em.getmetamodel(); entitytype<pet> pet_ = m.entity(pet.class); entitytype<owner> owner_ = m.entity(owner.class);  root<pet> pet = cq.from(pet.class); join<owner, address> address = cq.join(**pet_.owners**).join(**owner_.addresses**); 

pet_ instance of class entitytype doesn't define attribute named owners or addresses.

they define classes named pet_ , owner_ metamodel, importation here create conflict variable names ... right?

__

(the question related one)

this example incorrect, authors mixing canonical static metamodel classes (generated) classes obtained via metamodel api. supposed use either weakly typed api or stronlgy typed generated classes, not both together. in case, pet_ (which incredible bad naming choice , misleading) indeed doesn't have owners attribute. should reported, part of tutorial misleading , wrong.

see also


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -