I have tried Cassandra user defined data type example given by DataStax and I'm getting the below exception.
They did not specify how Address object should look like for this case. I have defined UDT type but it doesn't help.
Can any one help me how the Address class should look like?
java.lang.IllegalArgumentException: Cannot map unknown class com.att.opus.mytest.Address for field private com.att.opus.mytest.Address com.att.opus.mytest.Account.address
at com.datastax.driver.mapping.ReflectionMapper.getSimpleType(ReflectionMapper.java:321)
at com.datastax.driver.mapping.ReflectionMapper.extractType(ReflectionMapper.java:286)
at com.datastax.driver.mapping.ReflectionMapper$LiteralMapper.<init>(ReflectionMapper.java:65)
at com.datastax.driver.mapping.ReflectionMapper$LiteralMapper.<init>(ReflectionMapper.java:59)
at com.datastax.driver.mapping.ReflectionMapper$ReflectionFactory.createColumnMapper(ReflectionMapper.java:372)
at com.datastax.driver.mapping.AnnotationParser.convert(AnnotationParser.java:154)
at com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:103)
at com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:119)
at com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:76)
at com.att.opus.mytest.AccountMapper.test(AccountMapper.java:12)
at com.att.poc.Main.accountTest(Main.java:53)
at com.att.poc.Main.main(Main.java:40)
Not sure it the problem still persists, but it seems that Your Address class should be annotated with #UDT annotation, as described here
Related
How would I go about overriding AbstractCassandraConfiguration to use my own function to create a schema. I would like to be able to set up a Cassandra instance using a cql script that I select at runtime.
I have tried to override CassandraSessionFactoryBean.performSchemaAction() when it is created in AbstractCassandraConfiguration.session(). This causes cqllib to fail with
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
This seems to be related to how cqlib creates proxies: Superclass has no null constructors but no arguments were given
You can override getStartupScripts() in AbstractCassandraConfiguration. In there, you can do anything you want to. It's used by CassandraCqlClusterFactoryBean's executeSpecsAndScripts method (which is called in afterPropertiesSet).
I have a wcf service and i want to pass a string[] through it. I am receiving the below error. Can someone point me in the right direction ?
The error :
There was an error while trying to serialize parameter http://services.csssoftware.com/2.0/ComFacades:arParams. The InnerException message was 'Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.
If you need more data plese let me know and i will edit the question.
For others who get to the same error, the fix was to add :[ServiceKnownType(typeof(string[]))] in my interface class.
For more information about this problem you can read : HERE
I have an XPT template that generates text from a UML model. This is the excerpt I use on the attributes of a class
«FOREACH attribute AS a»
Id: «a.name»
Type: «a.type.name»
«ENDFOREACH»
All works well as long as the type is a class from the model itself. But if it is a primitive type, then all of the fields, including the name, is set to null. If I change «a.type.name» to «a.type», then the response is something like this:
org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl#6e315086 (eProxyURI:
pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String)
The debugger shows that only the eStorage private field is set on the object that is why the toString() produces the output above.
Interestingly the same expression in Acceleo is evaluated correctly:
[query public getType(t : Type) : String = t.name /]
Question: how can I get the type field of attributes be filled in for primitive uml types in Xtend?
EDIT: Issue narrowed down to this question: EProxy URI does not resolve in ecore model
The code generated by Acceleo can resolve the unusual pathmap:// eProxyURIs. By default, a simple Xpand template or Xtend code can't resolve them. See this question for more details and the solution.
I have a class marked as CollectionDataContract which has a enum member. When I place an object of this class in Appfabric, I am through. When I get it back from App fabric, it does not deserialize the enum member. But I am not sure if the enum has been missed out in Serialization part itself.
Please do help.
If you need more information let me know.
Thanks.
[CollectionDataContract]
public partial class RuleConditionList : List<IRuleCondition>, IRuleCondition
{
public LogicalOperator Operator;
}
where LogicalOperator is an enum
I think there is a problem when serializing/deserializing your object. AppFabric uses the NetDataContractSerializer class for serialization before storing the items in the cache.
You can use the NetDataContractSerializer on any type which are marked with the DataContractAttribute or SerializableAttribute, or types that implement the ISerializable interface.
So depending and your object, there should be something wrong like a private type, a private field, a missing attibute, ...
Edit
You should add DataMember to your field.
[DataMember]
public LogicalOperator Operator;
Any data member in a class marked with Collection data contract cannot be serialized by NetdataContractSerializer which is the serailization technique used by App fabric for storing data.
To make things work we have two options:
Make a wrapper for RuleConditionList
Instead of Inheriting from List, make it as a property and change the attribute as DataContract.
I have class A that derives from System.Data.Objects.DataClasses.EntityObject.
When I try to serialize using
var a = new A();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(a.GetType());
serializer.WriteObject(Response.OutputStream, a);
I get error
TestController+A._Id' is not marked with OptionalFieldAttribute, thus indicating that it must be serialized. However, 'TestController+A' derives from a class marked with DataContractAttribute and an IsReference setting of 'True'. It is not possible to have required data members on IsReference classes. Either decorate 'TestController+A._Id' with OptionalFieldAttribute, or disable the IsReference setting on the appropriate parent class.
Even if I decorate the field with OptionalFieldAttribute I get
The type 'TestController+A' cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.
I cannot modify EntityObject class. I thought to create A_Bag class exactly as A class and fill it and serialize it instead of A, but I think there's more elegant way to do it.
Can you suggest how I can do it?
I think you can use a "data contract surrogate" here (used via the IDataContractSurrogate interface.)
The data contract surrogate is an advanced feature built upon the Data Contract model you're already using. It lets you do type customization and substitution in situations where you want to change how a type is serialized, deserialized, or (if you're dealing with XML) projected into schema.
In your case, the use of IDataContractSurrogate lets you do custom JSON serialization and deserialization on a per-type or per-object basis. An IDataContractSurrogate would provide the methods needed to substitute one type for another by the DataContractSJsonerializer during serialization and deserialization, and you may want to provide a different "special" intermediary type for your scenario.
Hope this helps!
JSON.Net supports serialization of objects marked with IsReference=true.
There is a detailed walkthrough here:
http://dotnet.learningtree.com/2012/04/03/working-with-the-entity-framework-and-the-web-api/