-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Int32 MongoDB data type problem
PostPosted: Fri Oct 30, 2015 12:45 am 
Newbie

Joined: Fri Oct 30, 2015 12:37 am
Posts: 2
My company has a 3 years old MongoDB database with 250GB of data.
I am converting the source code from using Resin + Redis + MongoDB to Wildfly + Infinispan + JPA + MongoDB
The reason is I want to have a more unified way to work with data. By using Hibernate OGM through JPA, what I want to archive is having a single API to work with both Infinispan and MongoDB.

The problem is my database is using Int32 and Int64 for some of its field. Right at the moment:

When I use
@Column(name = "app_status")
private Long appStatus;
It says: "Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field vn.eway.adsinapp.model.App.appStatus to java.lang.Integer"
When I use
@Column(name = "app_status")
private Integer appStatus;
It says: "It says: "Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field vn.eway.adsinapp.model.App.appStatus to java.lang.Integer"

My question is: what data type should I use to map with Int32 and Int64 of MongoDB?


Top
 Profile  
 
 Post subject: Re: Int32 MongoDB data type problem
PostPosted: Fri Oct 30, 2015 3:12 am 
Newbie

Joined: Fri Oct 30, 2015 12:37 am
Posts: 2
well, I found the solution. Int32 should be mapped to Short.


Top
 Profile  
 
 Post subject: Re: Int32 MongoDB data type problem
PostPosted: Mon Nov 23, 2015 7:48 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hey,

Sorry for the late response, just stumbling over this. Actually you should use int/Integer to map Int32. Short would be to small so you are at risk of value loss. Your second error report seems weird:

Code:
@Column(name = "app_status")
private Integer appStatus;

It says: "Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field vn.eway.adsinapp.model.App.appStatus to java.lang.Integer"


The field is of type Integer, whereas the error message says it's Long. Could you double check whether that was not a mix-up from different experiments or so?

If that's what you actually get with the field being of type Integer, I'd consider it a bug in OGM. Could you file a JIRA issue and attach a test case, please?

Thanks,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.