Author author = new Author(); save(author); Book book = new Book(); book.setAuthor(author); save(book); Book goodBook = new Book(); goodBook.setAuthor(author); save(goodBook);
public void updateUserAgeByName(String name, int age) { User user = fetchUserByName(name); user.setAge(age); updateUser(user); }
//... the deserialized original JSON ItemLegacy legacy ... // create an author Author author = new Author(); author.setName(legacy.getName()); author.setGroup(legacy.getGroup()); ... // create an item Item item = new Item(); item.setTitle(legacy.getTitle()); ... // finally set the author... and you should have the desired structure item.setAuthor(author);
public void testEqInNested1() { QueryFactory qf = getQueryFactory(); // all users in a given post code Query q = qf.from(getModelFactory().getUserImplClass()) .having("addresses.postCode").eq("X1234") .build(); List<User> list = q.list(); assertEquals(1, list.size()); assertEquals("X1234", list.get(0).getAddresses().get(0).getPostCode()); }
@Test public void testUnicode() throws Exception { Author authorWithUnicode = new Author(); authorWithUnicode.setName("Ilkka Seppälä"); authorRepository.save(authorWithUnicode); Author authorWithSpaces = new Author(); authorWithSpaces.setName("M Saif Asif"); authorRepository.save(authorWithSpaces); assertThat(authorRepository.findByName("Ilkka Seppälä").get()).isNotNull(); assertThat(authorRepository.findByName("Ilkka Seppala").get()).isNotNull(); assertThat(authorRepository.findByName("M Saif Asif").get()).isNotNull(); assertThat(authorRepository.findByName("MSaifAsif")).isEqualTo(Optional.empty()); }
public AccountHS() { // hardLimits is a required field, so we make our life easy by providing defaults here hardLimits = new LimitsHS(); hardLimits.setMaxTransactionLimit(5000.0); hardLimits.setMaxDailyLimit(10000.0); }
for (User user : list) { String userGender = user.getGender(); // call the getter method of gender from User class System.out.println(userGender ); }
@Override public List<Address> findAllAddress(int userId) { User user = userDAO.findOne(userId); if (user == null) { throw new BadRequestException("Invalid user id", 101); } List<Address> addresses = user.getAddresses(); if (addresses == null || addresses.isEmpty()) { throw new BadRequestException("Address Not found", 102); } return addresses; }
public void testParam() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where id = :idParam"); q.setParameter("idParam", 1); List<Transaction> list = q.list(); assertEquals(1, list.size()); assertEquals(1, list.get(0).getId()); q.setParameter("idParam", 2); list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0).getId()); }
// Declare the variable Author author; // Create an object (with the new operator) and assign the object to the variable author = new Author();
for (User user : list) { String gender = user.getGender(); System.out.println(gender); }
public Author getAuthor(){ return new Author(); // or some author that is set in your object }
for(int z=0;z<athr.length;z++){ athr[z]=new Author(); }
author_model.authors.add(new Author("New Author"));
var Author = Parse.Object.extend("Authors"); var myAuthor = new Author(); myAuthor.set("Name", "Dostoievski"); myAuthor.save().then(function(authorRes){ var Book = Parse.Object.extend("Books"); var myBook = new Book(); myBook.set("Title", "The Idiot"); myBook.save().then(function(bookRes){ var relation = bookRes.relation("authors"); relation.add(authorRes); bookRes.save({ success: function(relation) { console.log(relation); }, error: function(relation, error) { console.log(relation + "::" +error.code+"::"+error.message); } }); }); });
Author bob = new Author(); // You can set the name and email of the Author here using setters, // or add them as args in the Author constructor Book firstBook = new Book("The First Book", 1, bob); Book secondBook = new Book("The Second Book", 2, bob);