Spent some time to figure out why i cannot add properties on app context. Config was pretty trivial <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties" ref="configproperties" /> </bean> <bean id="configproperties" [...]
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
Today we’ve got such exception org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation quick investigation on Spring sources led us to issue with json serialization. We use jackson for converting from object to json behind the scene For Spring 3.x we configured <dependency> [...]
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