Grails warning at compile of controllers - grails

I am currently getting the warning in Grails of
'The [update] action accepts a parameter of type [edu.acu.teachereval.SubjectCode] which has not been marked with #Validateable. Data binding will still be applied to this command object but the instance will not be validateable.
#Transactional'
along with the same errors for show, save, edit, and delete for the controller mentioned in the error and other controllers that I have created. I have seen this issue for user created functions, but I have not seen this error for functions that are built in to grails. Any assistance would be appreciated.

I think you need to add a #Validateable annotation to your SubjectCode class.
Reference

This may be coming late, But this error is likely to occur when you use models not created in the domain conventional folder.
It seems grails automatically injects the #Validateable annotation to domain classes/models in the domain Folder,
If you therefore create your models in the src/grails or src/java folder, You are likely to get this error when the model object is passed/posted/submited via a View to a controller function.
Try adding the #Validateable annotation to the domain object
Move the domain model to the domain grails convention folder

or maybe Grails is overreaching while simultaneously giving misleading error messages... nah, that never happens. For a more relevant answer, see:
Groovy / Grails using a map as a parameter of a function

Related

Check for annotation present on superclass field

I have problems to check if a persistent property in grails has an specific annotation for fields that belong to superclass ... ane then get it's name and value.
I am getting the persistence properties as:
GrailsDomainClassProperty[] persistentProperties = new DefaultGrailsDomainClass(entityClass).getPersistentProperties();
That works great ... but later i found that getDeclaredFields only retrieves the actual class fields (not superclass) and things starts to look not very Groovy.
Is there a prefered Groovy way to do this?
No, you should use this code for all super classes. The same will be for children classes.

Error generating <DbContext>

I am trying stuff out on MVC4 Beta. Project is in VS11, EF 5.0-Beta, using Code First approach.
Created simple Model poco and DbContext derived class with single IDbSet<> property for model class. Connection string with LocalDb.
I noticed when context's Entity Set property is type of IDbSet<> then I get message from VS when I try to create new controller with “Controller with read/write actions and views, using Entity Framework” Scaffolding template:
"There was an error generating 'MyProject.MyNamespace.MyContext'. Try rebuilding your project."
Even Clean Solution and building again doesn’t help.
If I changed Entity Set property to type DbSet<> then controller scaffolding succeeds.
Is it a bug or is it expectable?
Br,
Lauri
It is not a bug you cant instantiate an instance of an Interface. The I in front of IDbSet denotes the type as an interface (By convention). So you were trying to create an instance of that interface. Instead you need to delcare it with DBSet<> which is an implementation of the IDBSet<> interface. I hope this clarifies your issue.

Where should I place a transient domain class in a grails app?

Where should I place a transient domain class in a grails app?
Ie I have an Action class that will be passed about, and used, but never saved. Should this be in the grails-app/domain folder, or somewhere else?
grails-app/domain is for persistent domain classes, but not all of your application's domain-related classes need to be there, e.g. in this case where you want to use it as a value object. You can put these in src/groovy along with other classes that aren't considered Grails artifacts.
If you want the classes to support validation, you can annotate them with #Validateable - see section "7.5 Validation Non Domain and Command Object Classes" in the ref docs: http://grails.org/doc/latest/
I think a CommandObject may fit the bill. These typically go in the same directory as your controllers, have the same validation features available to domain objects, but are never persisted. Great for things like search forms.

Two classes have the same xml type name

When I try to publish my Workspace in RAD, I get this error "Two classes have the same xml type name", probably because the same class name exists in the same package, but in two different jars. And it seems like that the #XmlType annotation needs to have distinct values for its attributes name and namespace in the sources of these classes. I tried wsdl2java available in Apache CXF, but I'm not able to make it generate this namespace attribute. I tried fiddling with the -p package option, but that's only for placing the generated sources in the specified package.
Any ideas how to generate this namespace attribute for each element encountered in the wsdl? TIA.
thanks to Daniel's anwser:
CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
i learned there is a parameter -xjc-npa for wsdl2java which helped me.
This will add XmlType.name and XmlType.namespace annotations to the generated classes so it won't be a problem if you have same class names but in different namespaces
I ran into this for an object named "SubmitDataResponse" that I was using as a return object from my web service method named "submitData". When I tried renaming the object, the error went away. It seems to me that CXF is creating its own return object based on the method name (in this case submitData() -> "SubmitDataResponse"). You may want to try renaming the class and see if you are having the same issue. Perhaps someone can chime in with a way to keep our class named the way we want them to (probably with some annotation).
I hope this helps.

Can't use code generators because of "object reference not set to an instance of..."

What can cause this behaviour?
I'm trying to generate code via ADO.NET EntityObject/Poco/SelfTracking Generator and i get only "object reference not set to an instance of an object" error
I can add i'm using EF4 with OracleProvider and previously i've generated code with EdmGen2, but right now i'd like to generate POCO classes from existing .edmx file which was created above existing database.
I never used this feature, but you might want to look at the stack trace / inner exception of the exception, it will help you track the exception source so it will easier for users to help.
Or even maybe it's a broken relationship or maybe some line of your patial-class constructors or other functions is throwing this error.

Resources