-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE with generated value #292
Comments
Hi, -Vivek |
Please refer: for more on usage of @GeneratedValue over MongoDB. |
The original code uses it (@GeneratedValues). I'd like to map the original code as closely as possible before changing things, so yes, I need autogenerated primary keys. |
That link uses ObjectIds, which are familiar from mongo. It also uses @TableGenerator. The docs here: https://github.com/impetus-opensource/Kundera/wiki/Primary-Key-Auto-generation use Strings and no mention of @TableGenerator. I Followed the docs. What do I need to change? If my usage is not correct:
|
Did you try referrring to: for more on usage of @GeneratedValue over MongoDB. If yes, and still getting error, please share your code snippet link -Vivek |
KK, -Vivek |
"Did you try referrring to:" Yes. As I said, it is different from the docs:
Do I need to change both things, or just the type? I have 19 generated values in my code, so it's a fair bit of code to go over and I'd like to just change the type if that's all I need to change. Moreover:
|
As per Table generation strategy is only applicable to "Cassandra" and "HBase".
In case, you want _id field in mongodb to be of type ObjectId, then only you need to declare it as "ObjectId" in your entities. If you define them as "String" type, by default _id field in mongodb will persisted as auto generated "ObjectId.toString()", method
I will get them updated for above mentioned information, Thanks for pointing it out.
It should not be thrown and a proper message should have been displayed. I will verify it. Thanks, |
Version of Kundera referring to? Is it 2.5 or 2.5.1? -Vivek |
|
For:
Did you specify Entity with @table annotation, as for example:
To map it correctly with MongoDB, you need to add this over Entity definition. -Vivek |
Yes, I did that. IIRC, I also got a different mysterious error until I added that. It is possible I'm using some other unsupported annotations. |
Ok. Let me know, if you can carve out a sample example to verify and look into the issue. -Vivek |
Is @MappedSuperclass supported? |
Not yet. |
Thanks. That may be my issue. I can't tell with current error messages. |
I am porting some code and am getting this exception:
Caused by: java.lang.NullPointerException
at com.impetus.kundera.configure.MetamodelConfiguration.processGeneratedValueAnnotation(MetamodelConfiguration.java:452)
at com.impetus.kundera.configure.MetamodelConfiguration.scanClassAndPutMetadata(MetamodelConfiguration.java:370)
at com.impetus.kundera.configure.MetamodelConfiguration.loadEntityMetadata(MetamodelConfiguration.java:227)
at com.impetus.kundera.configure.MetamodelConfiguration.configure(MetamodelConfiguration.java:107)
at com.impetus.kundera.configure.Configurator.configure(Configurator.java:65)
at com.impetus.kundera.KunderaPersistence.initializeKundera(KunderaPersistence.java:109)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:81)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.xonami.rest.db.EMFactory.(EMFactory.java:19)
... 61 more
I assuming this has something to do with the @GeneratedValue annotations, but I can't figure out what. I am using mongodb. My annotations look like this:
Some of them are annotated with @column, some are not.
The text was updated successfully, but these errors were encountered: