Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @DatabaseField(columnName = "client_id",generatedId = true,useGetSet = true)
- private Integer clientId;
- @DatabaseField(columnName = "client_nom",useGetSet = true)
- private String clientNom;
- @DatabaseField(columnName = "city_id",foreign = true,useGetSet = true)
- private City city;
- @DatabaseField(columnName = "city_id",generatedId = true,useGetSet = true)
- private Integer cityId;
- @DatabaseField(columnName = "city_name",useGetSet = true)
- private String cityName;
- @ForeignCollectionField
- private ForeignCollection<Client> clientList;
- public class CityDao extends BaseDaoImpl<City, Integer> {
- private ClientDao clientDao;
- public CityDao(ConnectionSource cs, ClientDao clientDao) {
- super(cs, City.class);
- this.clientDao = clientDao;
- }
- ...
- @Override
- public int delete(City city) {
- // first delete the clients that match the city's id
- DeleteBuilder db = clientDao.deleteBuilder();
- db.where().eq("city_id", city.getId());
- clientDao.delete(db.prepare());
- // then call the super to delete the city
- return super.delete(city);
- }
- ...
- }
- @DatabaseTable(tableName = "cities", daoClass = CityDao.class)
- public class City {
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement