Skip to content
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

EntityManagerFactory with external properties throws NullPointerException #629

Closed
ansarrafique opened this issue Aug 5, 2014 · 12 comments
Closed
Labels
Milestone

Comments

@ansarrafique
Copy link

I am using Kundera 2.13. If I want to create entity manager factory with external properties, do I have specify ALL PERSISTENCE UNIT PROPERTIES in map ? I am getting NullPointerException if I specify some properties in persistence unit and some provided in map. Is this supported ?

@ansarrafique
Copy link
Author

I don't know if it has support yet in Kundera ?

@mevivs
Copy link
Collaborator

mevivs commented Aug 5, 2014

Few properties are mandatory. AFAIK But kundera.nodes should definite ly be overridden
Sent from Yahoo!7 Mail on Android

@mevivs
Copy link
Collaborator

mevivs commented Aug 5, 2014

AFAIK It is supported and should work. Kundera team?

Sent from Yahoo!7 Mail on Android

@ansarrafique
Copy link
Author

Apparently it works if properties already exist in persistence.xml configuration file and one is willing to override it OR there is an empty persistence-unit. I have a case when some properties can be defined in persistence.xml configuration file and some cannot.

@kkmishra
Copy link
Contributor

kkmishra commented Aug 6, 2014

Hi Ansar,

Please provide port along with host in property map.

Map<String, Object> test = new HashMap<String, Object>();
test.put("kundera.nodes", "localhost");
test.put("kundera.port", "port number");
entityManager =Persistence.createEntityManagerFactory("test",test);

Hope it will help you.

On Tue, Aug 5, 2014 at 7:48 PM, ansarrafique [email protected]
wrote:

Apparently it works if properties already exist in persistence.xml
configuration file and one is willing to override it OR there is an empty
persistence-unit. I have a case when some properties can be defined in
persistence.xml configuration file and some cannot.


Reply to this email directly or view it on GitHub
#629 (comment)
.

Thanks and Regards
Kuldeep Kumar Mishra
+919540965199

@sanjivsingh
Copy link

NullPointerException have occurred to me as well . I have seen only in case i override "kundera.nodes" only (not "kundera.port"). Other than that it will fetch other parameter property value from persistant.xml.

Map<String, String> paramMap = new HashMap<>();
paramMap.put("kundera.nodes", host);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("CassandraPU", paramMap);

For me,if you override "kundera.nodes" property , then you must override "kundera.port" property. which is not expected. If "kundera.port" is not there in argument map, then it should get it from persistant.xml.

@mevivs
Copy link
Collaborator

mevivs commented Aug 6, 2014

Keep a dummy value of kundera.nodes and kundera.host in persistence.xml and override as many times as you want. This is an issue or a protocol? Kundera team can decide on it. IMHO, having dummy or fallback configuration in persistence.xml is a better configuration

-Vivek

@ansarrafique
Copy link
Author

Hi Kuldeep and Vivek,

Thank you for your reply. As I said, there is no problem if dummy properties or even properties with real values are defined in persistence.xml file. The map properties will override it. The only case I see, if node property doesn't exist in persistence.xml and is provided via map. In idea case it should not be an exception, but it's not a big requirement I guess so things are cool so far. Thanks.

Ansar

@ansarrafique
Copy link
Author

Kundera team: Do you want me to close this issue ?

@impetus-opensource-admin
Copy link
Collaborator

Hi Ansar ... Although not a blocking one, but would suggest you to please keep this defect open. It's a small fix and we would deliver it next release.

@ansarrafique
Copy link
Author

Perfect, also now I can see a scenario when this would be a big plus. Thanks.

@chhavigangwal chhavigangwal added this to the 2.13.1 milestone Aug 8, 2014
@chhavigangwal chhavigangwal modified the milestones: 2.13.1, 2.14 Aug 20, 2014
DaVincii added a commit that referenced this issue Sep 29, 2014
DaVincii added a commit that referenced this issue Sep 29, 2014
@chhavigangwal chhavigangwal added Fixed and removed Fix labels Sep 29, 2014
@chhavigangwal
Copy link
Collaborator

Fixed with Kundera -2.14 Release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants