第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Azure 插入不添加實(shí)體的新屬性 (Java)

Azure 插入不添加實(shí)體的新屬性 (Java)

牛魔王的故事 2021-11-11 15:36:34
我有一個(gè)帶有 Azure 表存儲(chǔ)的數(shù)據(jù)庫(kù),我在其中存儲(chǔ)具有各種屬性的實(shí)體,并且一切運(yùn)行良好。但是,當(dāng)我嘗試添加新屬性時(shí),它根本沒(méi)有被存儲(chǔ)。我的 InsertEntity 代碼如下所示:LunchDateEntity entity = new LunchDateEntity(ID);try{AppStorage storage = new AppStorage(TABLENAME);entity.setProperty1(prop1)entity.setProperty2(prop2)entity.setProperty3(prop3)entity.setNewProperty(newProp)TableOperation operation = TableOperation.insert(entity);m_table.execute(operation);} catch(...) {...}Prop 1,2,3 是我以前擁有的實(shí)體,它們被添加到表存儲(chǔ)中,但是,newProp 根本沒(méi)有在表存儲(chǔ)中顯示。我嘗試在構(gòu)建實(shí)體時(shí)對(duì)該屬性進(jìn)行硬編碼,但無(wú)濟(jì)于事。我的實(shí)體類(lèi)看起來(lái)像:public class myEntity extends TableServiceEntity {public static final String TABLENAME = "myTable";public static final String PARTITION_KEY = "part1";public String m_prop1 = "";public String m_prop2 = "";public String m_prop3 = "";public String m_newProp = "";public myEntity() { this.partitionKey = PARTITION_KEY;} public void setProp1(String prop1) {  m_prop1 = prop1;}public String getProp1() { return m_prop1;}public void setNewProp(String newProp) { m_newProp = newProp;}對(duì)于所有屬性,依此類(lèi)推。他們都長(zhǎng)得很像。我是否誤解了插入功能的工作原理?有什么想法為什么這不起作用?提前致謝
查看完整描述

1 回答

?
Qyouu

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊

根據(jù)我的測(cè)試,我認(rèn)為這是因?yàn)槊Q(chēng)規(guī)則。我測(cè)試了添加 newProp 或 newProp1 字段,與您的解決方案相同。新房沒(méi)有出現(xiàn)。


然后我嘗試添加姓名、電話(huà)或什至 oldProp,一切正常。


功能代碼:


@FunctionName("addentity")

    public String addentity(@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) String req,

                            ExecutionContext context) {


        String storageConnectionString =

                "***";

        String jsonStr = "insert failed";


        try {

            // Retrieve storage account from connection-string.

            CloudStorageAccount storageAccount =

                    CloudStorageAccount.parse(storageConnectionString);


            // Create the table client.

            CloudTableClient tableClient =

                    storageAccount.createCloudTableClient();


            // Create a cloud table object for the table.

            CloudTable cloudTable = tableClient.getTableReference("test");


            // Create a new customer entity.

            myEntity entity = new myEntity("jay1","gong");

            //entity.setProp1("a");

            entity.setNewProp("new");

            entity.setOldProp("old");

            //entity.setNewProp1("new1");

            //entity.setName("kkkkk");


            // Create an operation to add the new customer to the people table.

            TableOperation insertEntity =

                    TableOperation.insert(entity);


            // Submit the operation to the table service.

            cloudTable.execute(insertEntity);


            jsonStr = entity.toString();


        } catch (Exception e) {

            // Output the stack trace.

            e.printStackTrace();

        }



        return jsonStr;

    }

我的實(shí)體:


package com.fabrikam.functions;


import com.microsoft.azure.storage.table.TableServiceEntity;


public class myEntity extends TableServiceEntity {


    public String m_prop1 = "";

    public String m_newProp = "";

    public String m_newProp1 = "";


    public String name = "";

    public String oldProp = "";


    public myEntity(String lastName, String firstName) {

        this.partitionKey = lastName;

        this.rowKey = firstName;

    }


    public void setProp1(String prop1) {

        m_prop1 = prop1;

    }


    public String getProp1() {

        return m_prop1;

    }



    public String getNewProp(String newProp) {

        return m_newProp;

    }


    public String getNewProp1(String newProp1) {

        return m_newProp1;

    }



    public void setNewProp(String newProp) {

        m_newProp = newProp;

    }


    public void setNewProp1(String newProp1) {

        m_newProp1 = newProp1;

    }


    public String getName() {

        return name;

    }


    public void setName(String name) {

        this.name = name;

    }


    public String getOldProp() {

        return oldProp;

    }


    public void setOldProp(String oldProp) {

        this.oldProp = oldProp;

    }

}

輸出:

http://img1.sycdn.imooc.com//618cc8250001eb9810880435.jpg

我認(rèn)為'newProp'Azure 表存儲(chǔ)保留了類(lèi)似的內(nèi)容,您可以調(diào)整名稱(chēng)規(guī)則,然后一切都會(huì)好起來(lái)的。


我做進(jìn)一步的測(cè)試:

http://img1.sycdn.imooc.com//618cc8330001b97d10950309.jpg

只是為了總結(jié),最后,這完全是關(guān)于我的 getter 和 setter 的錯(cuò)誤格式。我們需要檢查對(duì)象定義。


查看完整回答
反對(duì) 回復(fù) 2021-11-11
  • 1 回答
  • 0 關(guān)注
  • 203 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)