Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @DatabaseField(columnName = "client_id",generatedId = true,useGetSet = true)
  2. private Integer clientId;
  3. @DatabaseField(columnName = "client_nom",useGetSet = true)
  4. private String clientNom;
  5. @DatabaseField(columnName = "city_id",foreign = true,useGetSet = true)
  6. private City city;
  7.  
  8. @DatabaseField(columnName = "city_id",generatedId = true,useGetSet = true)
  9. private Integer cityId;
  10. @DatabaseField(columnName = "city_name",useGetSet = true)
  11. private String cityName;
  12. @ForeignCollectionField
  13. private ForeignCollection<Client> clientList;
  14.  
  15. public class CityDao extends BaseDaoImpl<City, Integer> {
  16. private ClientDao clientDao;
  17. public CityDao(ConnectionSource cs, ClientDao clientDao) {
  18. super(cs, City.class);
  19. this.clientDao = clientDao;
  20. }
  21. ...
  22. @Override
  23. public int delete(City city) {
  24. // first delete the clients that match the city's id
  25. DeleteBuilder db = clientDao.deleteBuilder();
  26. db.where().eq("city_id", city.getId());
  27. clientDao.delete(db.prepare());
  28. // then call the super to delete the city
  29. return super.delete(city);
  30. }
  31. ...
  32. }
  33.  
  34. @DatabaseTable(tableName = "cities", daoClass = CityDao.class)
  35. public class City {
  36. ...
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement