Dear all, I'm a Sculptor and OAW newbie, but I'm impressed with the platform possibilites. I'm using Sculptor 1.6.0
I think I have found a bug on the code generator in the Web CRUD project of Sculptor, related to inheritance and Many-to-Many relations. If I make Many-To-Many relationships between an Entity and its parent, or with the Parent with himself, web application classes does not compile because of a casting error. I have tried to solve it, using WebSpecialCases.xpt, but I receive some strange (to me) errors. At first I will show you an example of the bug. Later I will explain how I tried to solve it, and where I'm stuck. Module inheritanceSample { abstract Entity Parent { scaffold String name key String description - Set<@Parent> buyer <-> seller - Set<@Parent> seller <-> buyer - Set<@SonOne> sonone <-> dad } Entity SonOne extends @Parent { scaffold String data1 - Set<@Parent> dad <-> sonone } } When I generate the code, I works. However, when I run "mvn -Dmaven.test.skip=true clean install" there are compilation errors: /proyectos/sculptoride/workspaces/remato/remato-web/src/generated/java/es/aww/remato/inheritanceSample/web/UpdateSonOneAction.java:[98,33] incompatible types found : java.util.List<es.aww.remato.inheritanceSample.domain.SonTwo> required: java.util.Collection<es.aww.remato.inheritanceSample.domain.Parent> /proyectos/sculptoride/workspaces/remato/remato-web/src/generated/java/es/aww/remato/inheritanceSample/web/CreateSonOneAction.java:[73,35] incompatible types found : java.util.List<es.aww.remato.inheritanceSample.domain.SonThree> required: java.util.Collection<es.aww.remato.inheritanceSample.domain.Parent> The problem is with the code at the Update<Entity>Action and Create<Entity>Action classes. This is a sample of the broken code (from UpdateSonOneAction.java): protected List<SelectItem> getSonOneItems() { Collection<Parent> buyer = sonOneService.findAll(ServiceContextStore.get()); List<SelectItem> items = new ArrayList<SelectItem>(); for (Parent parentItem : buyer) { if (parentItem instanceof SonOne) { String label = String.valueOf(parentItem.getName()); items.add(new SelectItem(parentItem.getId(), label)); } } return items; } The problem is with the generic "Collection<Parent> buyer". The "sonOneService.findAll" method returns "List<SonOne>" which can not be directly cast to "Collection<Parent>". Fortunately, using wildcards with generics (See: http://today.java.net/pub/a/today/2004/01/15/wildcards.html?page=2) the offending line can be fixed: Collection<? extends Parent> buyer = sonOneService.findAll(ServiceContextStore.get()); As changing the code manually is boring, I tried to fix the generator. I downloaded the Sculptor 1.6.0 branch from the repository and I searched for the template. It is JSFCrudGuiJava.xpt at the templates.web package. The definition in the file is "getReferenceItems". So I created a rule at WebSpecialCases.xpt to overwrite that definition. Note that it is a very naive solution, as I don't know the posible impact on other parts: «IMPORT sculptormetamodel» «IMPORT sculptorguimetamodel» «EXTENSION extensions::helper» «EXTENSION extensions::dbhelper» «EXTENSION extensions::properties» «EXTENSION extensions::guihelper» «AROUND *getReferenceItems FOR ReferenceViewProperty» «LET getRelatedAddTask() AS addTask» protected java.util.List<javax.faces.model.SelectItem> get«target.name.toFirstUpper()»Items() { java.util.Collection<? extends «reference.to.getDomainPackage()».«reference.to.name»> «name» = «addTask.getPrimaryService().name.toFirstLower()».«addTask.getPrimaryServiceOperation().name»(«IF isServiceContextToBeGenerated()»«serviceContextStoreClass()».get()«ENDIF»); java.util.List<javax.faces.model.SelectItem> items = new java.util.ArrayList<javax.faces.model.SelectItem>(); for («reference.to.getDomainPackage()».«reference.to.name» «reference.to.name.toFirstLower()»Item : «name») { if («reference.to.name.toFirstLower()»Item instanceof «target.getDomainPackage()».«target.name») { String label = «EXPAND itemLabel(reference.to.name.toFirstLower()+"Item") FOR reference.to -»; items.add(new javax.faces.model.SelectItem(«reference.to.name.toFirstLower()»Item.getId(),label)); } } return items; } «ENDLET» «ENDAROUND» However, when I tried that, I obtained a null pointer exception (See the attached stacktrace for more detail). I guess that the problem is that I can not reference values from the original template. Could you please explain me how can I do it? Also, could you please also confirm if the inheritance problem is a bug? I have found similar problems in JIRA, but i don't know if this is related to them. Thanks in advance for your responses, best regards, http://www.nabble.com/file/p25238074/sculptor-inheritance-stacktrace.txt sculptor-inheritance-stacktrace.txt -- View this message in context: http://www.nabble.com/-Sculptor--Possible-Inheritance-bug-in-Web-Application-and-problems-with-WebSpecialCases.xpt-tp25238074s17564p25238074.html Sent from the Fornax-Platform mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Fornax-developer mailing list Fornax-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fornax-developer