.NET sdk use data upsert and Spring framwork Findone null

#1

Couchbase SDK .NET(Ver:2.2.2) and SpringFramework(Ver:1.4.2.RELEASE) used

[ Test Case ]

  1. .NET Upsert -> .NET GetDocument : Success

  2. Spring Save -> Spring FindOne : Success

  3. Spring Save -> .NET GetDocument : Success

4. .NET Upsert -> Spring FindOne : Fail

Why shouldn’t I do not know … Help me please

.NET Code

var config = new ClientConfiguration
{
    Servers = new List<Uri>
    {
        new Uri("http://127.0.0.1:8091/pools")
    },

    Serializer = () => new JilSerializer()
};

using (var cluster = new Cluster(config))
{
    IBucket bucket = null;
    try
    {
        bucket = cluster.OpenBucket("Test", "Test");

        cItemInfo TempClass = new cItemInfo();
        for (int i = 0; i < 3; i++)
        {
            TestClass temp = new TestClass();
            temp.var1 = i;
            temp.var2 = i;
            temp.var3 = ".NET Testing";
            TempClass.test.Add(temp);
        }
        TempClass.result = 200;

        string jsonStr = JsonConvert.SerializeObject(TempClass);

        var document = new Document<cItemInfo>();
        document.Id = "TestClass_NET";
        document.Content = TempClass;

        var upsert = bucket.Upsert(document);
        if (upsert.Success)
            Console.WriteLine("Success");

        Console.Read();
    }
    finally
    {
        if (bucket != null)
        {
            cluster.CloseBucket(bucket);
        }
    }
}

Spring Framework Code

// [WS_ItemInfo.java]
@RequestMapping("GetItemInfoEx")
public @ResponseBody C_ItemInfo  GetItemInfoEx() {
    C_ItemInfo item = itemInfo.getItemInfo("TestClass_NET");
    return item;
}

// [CS_ItemInfo.java]
@Component
public class CS_ItemInfo {

@Autowired
private CR_ItemInfo itemInfo;

public void setItemInfo(C_ItemInfo item) {
    itemInfo.save(item);
}

public C_ItemInfo getItemInfo(String uID) {
    return itemInfo.findOne(uID);
}

public boolean getItemInfoExists(String uID) {
    return itemInfo.exists(uID);
}
}

// [CR_ItemInfo.java]
public interface CR_ItemInfo extends CrudRepository<C_ItemInfo, String> {

}

// [CouchbaseConfig.java]
@EnableCouchbaseRepositories
@Configuration
public class CouchBaseConfig extends AbstractCouchbaseConfiguration {

    @Override
    protected List<String> bootstrapHosts() {
        return Arrays.asList("127.0.0.1");
    }

    @Override
    protected String getBucketName() {
        return "test";
    }

    @Override
    protected String getBucketPassword() {
        return "test";
    }

    @Bean
    public MappingCouchbaseConverter mappingCouchbaseConverter() throws Exception {
        MappingCouchbaseConverter converter = new MyMappingCouchbaseConverter(couchbaseMappingContext());
        converter.setCustomConversions(customConversions());
        return converter;
    }

    private class MyMappingCouchbaseConverter extends MappingCouchbaseConverter {
        public MyMappingCouchbaseConverter(
                MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> mappingContext) {
            super(mappingContext);

            typeMapper = new DefaultCouchbaseTypeMapper(null);
        }
    }
}
#2

@sung0098 which versions are you using for .net and for spring-data-couchbase ?

#3

Couchbase Ver
Spring Framework : 1.4.2.RELEASE
.NET : 2.2.2

#4

Hi,
Spring Data Couchbase 1.4.2 is based on the “older” generation of SDKs (Java SDK 1.4.2 as well). Cross-compatibility between SDKs was not supported with this generation and was a focus of the second generation of SDKs (to which the .NET 2.2.2 belongs, but not the Java 1.4.2 one).

Second-generation Spring Data Couchbase 2.0.x is currently in Release Candidate and should produce documents that are cross-compatible with .NET 2.2.2.

#5

spring Data Version 2.0.0.RC1 has been resolved.
Thank you very much~~~

#6

Also note @sung0098 that if you need to get at the data created by the older Java client from the newer .NET client we can guide you with a transcoder. It’s possible to do, but just requires a bit of additional code/configuration.