-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[orm]: id filed can use other name with @BsonId annotation
- Loading branch information
1 parent
4bc8650
commit e6544ea
Showing
3 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
orm/src/test/java/com/zfoo/orm/accessor/IdAnnotationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2020 The zfoo Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.zfoo.orm.accessor; | ||
|
||
import com.zfoo.orm.OrmContext; | ||
import com.zfoo.orm.entity.MailEntity; | ||
import com.zfoo.protocol.util.StringUtils; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
import java.util.Date; | ||
|
||
@Ignore | ||
public class IdAnnotationTest { | ||
|
||
@Test | ||
public void batchInsertTest() { | ||
var context = new ClassPathXmlApplicationContext("application.xml"); | ||
for (int i = 0; i < 100; i++) { | ||
insertMail(StringUtils.format("mail-{}", i)); | ||
} | ||
} | ||
|
||
public void insertMail(String mailId) { | ||
OrmContext.getAccessor().delete(mailId, MailEntity.class); | ||
var mailEntity = MailEntity.valueOf(mailId, "userName-" + mailId, "content" + mailId, new Date()); | ||
OrmContext.getAccessor().insert(mailEntity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters