I am using the Grails MongoDb plugin and trying to get the Date conversion.
In my config I have defined different dateFormats
grails.databinding.dateFormats = [
'yyyy-MM-dd',
'yyyy-MM-dd HH:mm:ss.S',
"yyyy-MM-dd'T'hh:mm:ss'Z'"
]
However when I read a record from mongodb into my Customer domain class, I still get this error: What am I doing wrong?
org.springframework.beans.TypeMismatchException: Failed to convert
property value of type 'java.lang.String' to required type
'java.util.Date' for property 'lastUpdateDate'; nested exception is
org.springframework.core.convert.ConversionFailedException: Failed to
convert from type java.lang.String to type
#org.grails.databinding.BindingFormat java.util.Date for value
'1994-01-29T00:00:00Z'; nested exception is
java.lang.IllegalArgumentException: java.lang.NumberFormatException:
For input string: "1994-01-29T00:00:00Z"
It looks like you have manually inserted the value of lastUpdateDate in your MongoDB database which got stored in String format instead of MongoDB's ISODate() format. Delete or modify that record in database and this will work fine.
Related
I have a code that reads and writes into a table, which has a field of bit(1). When I am reading this table hibernate converts this into boolean just fine but when I try to save to it, it gives me column is type bit but expression is type boolean. I cannot change this field to boolean at db aide.
So far I tried seeling #Type, attribute converter and columnDefinition=Bit but still not working.
Please help
I am trying to save a Boolean value from Java using jpa repo which is Bit(1) field in postgres SQL db but getting error while doing insert or update.When I am reading this table hibernate converts this into boolean just fine but when I try to save to it, it gives me column is type bit but expression is type boolean. I cannot change this field to boolean at db aide.
I have a mongo database that contains a list of DBRef objects. I am converting this collection into a data frame in spark.
This gives the below error. Does anyone know how to resolve this error ??
EDIT:: Conversion to dataframe gives following error -> org.codehaus.janino.InternalCompilerException: Two non-abstract methods "public int scala.collection.TraversableOnce.size()" have the same parameter types, declaring type and return type
The error got resolved after upgrading the version of "org.codehaus.janino" to 3.0.9 (previously, I was using 3.0.8).
I have this below error :
SEVERE: 2018-03-17T17:15:42.272Z: java.lang.IllegalArgumentException: Unable to encode element 'BeamRecord [dataValues=[2/12/2017], dataType=BeamRecordSqlType [fieldNames=[c0], fieldTypes=[12]]]' with coder 'org.apache.beam.sdk.coders.BeamRecordCoder#56ce2595'.
I have specified dataValues=[2/12/2017] as TIMESTAMP datatype. link
Any idea whats going wrong here ?
It is likely you're using incorrect type for the TIMESTAMP field. BeamRecord expects a value of type java.util.Date in the TIMESTAMP fields.
If your input is coming from JSON, for example, you might need to parse the timestamp field using java.text.DateFormat, see example here.
If you're specifying the TIMESTAMP in the query, then try specifying the timestamp in this format: TIMESTAMP '1999-02-22 01:01:58'. See examples here.
I have the oracle database field value "11-JUL-16 02.51.45.000000000 AM" for field date_updated.
When I retrieve records via orm lite query and iterate over the result set .. I get the data in this format "2016-7-11.2.51. 45. 0" where the java pojo object mapping field is of type String.
Aim is to update these timestamps after processing them. I am not able to covert the date to update(parse error) or retrieve the date as is.
Searched allover but couldn't find an answer. I tried changing the pojo field type to Date/Timestamp(sql) but couldn't get it to work. Any Help would really appreciate ..
I'm using OrientDB and trying to create new property after I inserted my data (millions of rows).
I'm trying to create property on V in order to create an index and I'm getting the following error:
The database contains some schema-less data in the property
'V.ACCOUNT_NO' that is not compatible with the type STRING. Fix those
records and change the schema again [ONetworkProtocolHttpDb]
Now part of the fields type is INTEGER but it seems to me that it's very easy to convert the type to STRING.
how can I do it to the entire data?
I tried your case by creating this simple structure in schema-less mode:
These records are a mix of INTEGER and STRING types:
Now you can convert the not string records type by using this query:
UPDATE V SET ACCOUNT_NO = ACCOUNT_NO.asString() WHERE ACCOUNT_NO.type() <> 'STRING'
Output:
About the exception, I got correctly the same error when I try to create a new property V.ACCOUNT_NO of type STRING in schema-full mode and this is correct because the property already exists in the database and contains mixed types of records, although in schema-less mode.
Once all the records were converted, you'll able to create the new property.
Hope it helps