morphiaorg / critter Goto Github PK
View Code? Open in Web Editor NEWType safe criteria generator for morphia
License: Other
Type safe criteria generator for morphia
License: Other
Using Critter 4.1.1
Critter should ignore unrelated classes that aren't annotated as Morphia entities, but doesn't
How to reproduce
Clone https://github.com/felixxxxxs/critter-bug-showcase and run the critter:generate goal. Besides MyEntityCriteria.java, there will also be an ApplicationCriteria.java and a NonMorphiaClassCriteria.java, which shouldn't be generated.
e.g., critter/tests/gradle/kotlin/build/generated/critter/dev/morphia/critter/codec/UserEncoder.kt: (71, 10): 'postPersist(Any, Document, Mapper): Unit' is deprecated. Deprecated in Java
When no package is specified in the pom, use the entity's package + ".criteria"
Using Morphia 2.2.3 and Critter 4.1.0 on Java 11, Failed to execute goal dev.morphia.critter:critter-maven:4.1.0:generate (critter) on project: A type incompatibility occurred while executing dev.morphia.critter:critter-maven:4.1.0:generate
This happens even when I don't have any classes annotated with Morphia annotations.
Verbose output from Maven:
Caused by: java.lang.ClassCastException: class org.jboss.forge.roaster.model.impl.JavaEnumImpl cannot be cast to class org.jboss.forge.roaster.model.source.JavaClassSource (org.jboss.forge.roaster.model.impl.JavaEnumImpl and org.jboss.forge.roaster.model.source.JavaClassSource are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @32177fa5)
at dev.morphia.critter.java.JavaClass.<init> (JavaClass.kt:12)
at dev.morphia.critter.Walker.directoryWalkStep (Critter.kt:77)
at org.codehaus.plexus.util.DirectoryWalker.fireStep (DirectoryWalker.java:171)
at org.codehaus.plexus.util.DirectoryWalker.scanDir (DirectoryWalker.java:381)
at org.codehaus.plexus.util.DirectoryWalker.scanDir (DirectoryWalker.java:375)
at org.codehaus.plexus.util.DirectoryWalker.scanDir (DirectoryWalker.java:375)
at org.codehaus.plexus.util.DirectoryWalker.scanDir (DirectoryWalker.java:375)
at org.codehaus.plexus.util.DirectoryWalker.scanDir (DirectoryWalker.java:375)
at org.codehaus.plexus.util.DirectoryWalker.scan (DirectoryWalker.java:334)
at dev.morphia.critter.Critter.scan (Critter.kt:42)
at dev.morphia.critter.CritterMojo.execute (CritterMojo.kt:40)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
I've pulled in your Entity classes into a new project; included the 2 dependencies. The classes get generated; however, there are compilation errors:
InvoiceCriteria.java:[66,50] error: type UpdateResults does not take parameters.
Any help with this would be awesome.
Thanks,
Chris
is there a gradle plugin for Critter ? if so pls share coordinates and will that suffice to make IDEA "intellisense" aware of the critter generated specs i.e. is there something else one needs to do to configure Idea in the context of gradle/critter
thanks
To match the maven plugin
Does it support Gradle?
If a field is an array or a List, it doesn't make sense to order by those members and so those methods should be suppressed in the generated code. Depends on issue #1
Hello,
I tried to add critter to our maven project, but it fails with the following error. Removing module-info.java from the project resolves the error. Not sure, if this needs to be fixed in critter or roaster.
Thanks for your help,
Alexander Schepp
[ERROR] Failed to execute goal dev.morphia.critter:critter-maven:4.4.3:generate (critter) on project x: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Could not find type declaration in Java source - is this actually code? -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal dev.morphia.critter:critter-maven:4.4.3:generate (critter) on project sso-domain: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Could not find type declaration in Java source - is this actually code?
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Could not find type declaration in Java source - is this actually code?
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: org.jboss.forge.roaster.ParserException: Could not find type declaration in Java source - is this actually code?
at org.jboss.forge.roaster.spi.JavaParserImpl.parseUnit (JavaParserImpl.java:93)
at org.jboss.forge.roaster.Roaster.parse (Roaster.java:260)
at org.jboss.forge.roaster.Roaster.parse (Roaster.java:285)
at org.jboss.forge.roaster.Roaster.parse (Roaster.java:210)
at org.jboss.forge.roaster.Roaster.parse (Roaster.java:117)
at dev.morphia.critter.java.JavaContext$scan$2.invoke (JavaContext.kt:57)
at dev.morphia.critter.java.JavaContext$scan$2.invoke (JavaContext.kt:57)
at kotlin.sequences.TransformingSequence$iterator$1.next (Sequences.kt:210)
at kotlin.sequences.FilteringSequence$iterator$1.calcNext (Sequences.kt:170)
at kotlin.sequences.FilteringSequence$iterator$1.hasNext (Sequences.kt:194)
at dev.morphia.critter.java.JavaContext.scan (JavaContext.kt:108)
at dev.morphia.critter.Critter.scan (Critter.kt:36)
at dev.morphia.critter.CritterMojo.execute (CritterMojo.kt:62)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
e.g.:
class Person {
String firstName;
@Property("last")
String lastName;
}
would generate something like :
class PersonFields {
String firstName() { return "firstName"; }
String lastName() { return "last"; }
}
currently the API only allows for single updates
Hi,
I've tried to run the critter generate goal but it ended up with the previous error.
I used this configuration:
<plugin>
<groupId>dev.morphia.critter</groupId>
<artifactId>critter-maven</artifactId>
<version>4.1.0</version>
<executions>
<execution>
<id>critter</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<force>false</force>
<criteriaPackage>data</criteriaPackage>
<outputType>java</outputType>
</configuration>
</execution>
</executions>
</plugin>
Hello,
I'm getting the following issue with my code base, but due to lacking debug output, I can't pinpoint it to a file.
Thanks for your help,
Alexander Schepp
[ERROR] Failed to execute goal dev.morphia.critter:critter-maven:4.4.3:generate (critter) on project x: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Cannot invoke "org.jboss.forge.roaster.model.source.FieldSource.isStatic()" because the return value of "org.jboss.forge.roaster.model.source.PropertySource.getField()" is null -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal dev.morphia.critter:critter-maven:4.4.3:generate (critter) on project sso-domain: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Cannot invoke "org.jboss.forge.roaster.model.source.FieldSource.isStatic()" because the return value of "org.jboss.forge.roaster.model.source.PropertySource.getField()" is null
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution critter of goal dev.morphia.critter:critter-maven:4.4.3:generate failed: Cannot invoke "org.jboss.forge.roaster.model.source.FieldSource.isStatic()" because the return value of "org.jboss.forge.roaster.model.source.PropertySource.getField()" is null
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
Caused by: java.lang.NullPointerException: Cannot invoke "org.jboss.forge.roaster.model.source.FieldSource.isStatic()" because the return value of "org.jboss.forge.roaster.model.source.PropertySource.getField()" is null
at dev.morphia.critter.java.extensions.PropertySourceExtensionsKt.ignored (PropertySourceExtensions.kt:69)
at dev.morphia.critter.java.types.CritterClass.allProperties (CritterClass.kt:35)
at dev.morphia.critter.java.JavaCriteriaBuilder.processFields (JavaCriteriaBuilder.kt:68)
at dev.morphia.critter.java.JavaCriteriaBuilder.build (JavaCriteriaBuilder.kt:54)
at dev.morphia.critter.Critter.generateCriteria (Critter.kt:42)
at dev.morphia.critter.CritterMojo.execute (CritterMojo.kt:63)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
dependent on the ksp transition
see #180
Probably AND too
java.lang.StackOverflowError
at java.util.HashMap.hash(HashMap.java:338)
at java.util.HashMap.put(HashMap.java:611)
at org.bson.BasicBSONObject.put(BasicBSONObject.java:303)
at org.mongodb.morphia.query.FieldCriteria.addTo(FieldCriteria.java:107)
at org.mongodb.morphia.query.CriteriaContainerImpl.addTo(CriteriaContainerImpl.java:81)
at org.mongodb.morphia.query.CriteriaContainerImpl.addTo(CriteriaContainerImpl.java:97)
at org.mongodb.morphia.query.CriteriaContainerImpl.addTo(CriteriaContainerImpl.java:81)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.