Module: DAO
- Defined in:
- lib/ontomde-uml2-crank/crankJpa.rb
Constant Summary collapse
- DAOInterface =
"GenericDao"
- DAOQualifiedInterface =
"org.crank.crud.GenericDao"
Instance Method Summary collapse
- #jpa_addDAO! ⇒ Object
- #jpa_addNamedQuery ⇒ Object
- #jpa_addNamedQueryToAssociation!(a) ⇒ Object
- #super_jpa_addDAO! ⇒ Object
Instance Method Details
#jpa_addDAO! ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 52 def jpa_addDAO! if !context[:crank] super_jpa_addDAO! return end log.debug { "adding dao for #{self}" } p=umlx_package p_dao=p.umlx_getOrCreatePackage(context[:dbDAOsubPackage,"dao"],p) c=p_dao.umlx_createAndAddInterface(rdf_uri+"_dao") c.db_isDAO=RDF_TRUE c.db_isTransient=RDF_TRUE self.java_DAOClass=c c.java_persistentClass=self c.uml_name=uml_name_one+"DAO" i = umlx_getOrCreateClass("#{DAO::DAOInterface}<#{uml_name_one},Long>"); i.db_isTransient=RDF_TRUE i.java_isGeneric=RDF_TRUE c.umlx_createAndAddGeneralization(i) self.jpa_addNamedQuery log.debug { "DAO added: #{c.uml_name} in #{c.umlx_package.uml_name}"} c.java_import_add(DAO::DAOQualifiedInterface) c.java_import_add("#{self.java_qualifiedName}") end |
#jpa_addNamedQuery ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 82 def jpa_addNamedQuery namedQuery = "@javax.persistence.NamedQueries( {\n" namedQuery << " @javax.persistence.NamedQuery( name = \"#{self.java_Name}.readPopulated\",\n" namedQuery << " query = \"select distinct #{self.java_Name.downcase} from #{self.java_Name} #{self.java_Name.downcase} " umlx_ownedAndInheritedAttribute.each { |a| next if a.uml_type_one.db_isTransient? next if a.uml_isDerived? if !a.umlx_isAttribute? namedQuery << jpa_addNamedQueryToAssociation!(a) end } namedQuery << " where #{self.java_Name.downcase}.id=?\" )" namedQuery += "})" self.java_annotation_add(namedQuery) end |
#jpa_addNamedQueryToAssociation!(a) ⇒ Object
99 100 101 |
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 99 def jpa_addNamedQueryToAssociation!(a) return "left outer join fetch #{self.java_Name.downcase}.#{a.java_Name} " end |
#super_jpa_addDAO! ⇒ Object
51 |
# File 'lib/ontomde-uml2-crank/crankJpa.rb', line 51 alias super_jpa_addDAO! jpa_addDAO! |