If somebody (not you we know you can’t do such stupid thing) created table with name from list of reserved words like USER don’t forget to put square brackets around table name like select * from [USER] You should do the same with jdbc requests
Andriy Andrunevchyn
I found out interesting thing – when you debug your app with active connection to Mongo it could cause unexpected issue at least if use spring mongo data What I noticed If you remove all data from collection you will not be able insert any new record to that collection Sometimes getAll method could return […]
Andriy Andrunevchyn
I reinstalled my OS so that mongo either. When I deploy project, following error appeared in log Exception in thread "main" org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [xxx], username = [xxx], password = [x*******x] I spend few hours adding user in robomongo and directly [...]
Andriy Andrunevchyn
Assume we have following classes class Storage{ @OneToMany(mappedBy = "storage", cascade = CascadeType.ALL, targetEntity = Fruit.class, fetch = FetchType.LAZY) List fruits; } class Fruit{ String name; String owner; @ManyToOne @JoinColumn(name = "STORAGE_ID") Storage storage; } What you have to do if you would like find all storages with [...]
Andriy Andrunevchyn
Don’t use UNIQUE statement like LOGIN varchar(100) NOT NULL UNIQUE SqlServer will create constraint with random name like UQ__TableName__E39E26653F9E5D18 If you use some automation tool like Flyway you will not be able remove that constraint easily because each time when you recreate table you will get new constraint name Better [...]
Andriy Andrunevchyn
Lets assume we have bean MyBean with field createTime class MyBean{ public long id; public Date createTime; } if you execute following code MyBean bean = new MyBean(); Date time; bean.createTime = time; //save and get with hibernate save(bean); MyBean storedBean = getBeanById(bean.id); log.info("Times are equal: [...]
Andriy Andrunevchyn
Вирішив поколупатись із Spring Boot і Spring Data Jpa і знайшов цікаву штуку. По дефолту у спрінга стоїть якийсь супероптимальний неймінг spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy який використовує SNAKE_CASE і цей неймінг такий “ядучий” що навіть, якщо ви вказуєте явно camelCase назву для [...]
Andriy Andrunevchyn
Цікаву багу(особливість?) знайшов у mongo/spring-data-mongo Коли зберігаєш пустий ArrayList на зразок //value = new ArrayList(); mongoTemplate.save(new CacheElement(key, value), collectionName); То при вичитці монго повертає HashSet і відповідно кидає помилку java.lang.ClassCastException: java.util.HashSet cannot be cast to [...]
Andriy Andrunevchyn
Recent Comments