search
Giriş
Merhabalar arkadaşlar, Sitemizi programlama ile ilgilenen bütün arkadaşlarımızın Türkçe içerik konusunda çektiği sıkıntılar düşünülerek soru/cevap şeklinde bir etkileşimde bulunabilmesi için kurduk. Umuyoruz hepimiz için güzel bir deneyim olur. Hasscript Ekibi
0 oy
1.3k gösterim

Java bir entity oluşturup, veri tabanıdna dynamic veri çekmeye çalışyorum. Ama bir alttaki hatayı alıyorum, neyi gözden kaçırıyorum sizce.

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long calorieId;
    private long userId; 
    private Date activityDate; 
    private Double activityCalorie;

2017-07-23 01:16:45.042 ERROR 4376 --- [nio-8080-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.core.convert.ConversionFailedException: 

Failed to convert from type [java.lang.Object[]] to type [com.example.entity.MyEntityName] for value '{27, 8}'; nested exception is org.springframework.core.convert.ConverterNotFoundException: 

No converter found capable of converting from type [java.math.BigInteger] to type [com.example.entity.MyEntityName]] with root cause

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.math.BigInteger] to type [com.example.entity.MyEntityName]  at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324)   at  org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:206)   
 at org.springframework.core.convert.support.ArrayToObjectConverter.convert(ArrayToObjectConverter.java:66)   ......................
Java kategorisinde 2.0k puan

Herhalde group bu tarzı bir sorgu çekiyordun, ondan bu sorunu aldın. Group by tarzı birşey çekerken alıyorsan projection yapmak lazım.

select new Sonuc(count(u), m.field_1, m.field_2) 
  from 
MyEntity m 
  where m.filter_field=? group by m.field_1, m.field_2

Sonuc sınıfını tamımlamasını yaparak kullanabilirsin.

1 cevap

0 oy

Herhalde group bu tarzı bir sorgu çekiyordun, ondan bu sorunu aldın. Group by tarzı birşey çekerken alıyorsan projection yapmak lazım.

select new Sonuc(count(u), m.field_1, m.field_2) 
  from 
MyEntity m 
  where m.filter_field=? group by m.field_1, m.field_2

Sonuc sınıfını tamımlamasını yaparak kullanabilirsin.

6.2k puan

İlgili sorular

0 oy
1 cevap 414 gösterim
414 gösterim
hibernate ile veri tabanına tarihe göre bir veri çekmeye calışıyorum. Ancak sadece trunc() kullanıp saati,saniyeyi almak istemiyorum TRUNC( :date) kullandığımda hata alıyorum. @Query(select c from User c where c.insertDate = TRUNC( :insertDate ); User findByDate (Date insertDate); Not: DATE(c.insertDate) denenebileceğini söyleyen kaynaklar var, bununla ne farkı var bilen var mı?
16 Temmuz 2017 Java kategorisinde tolgacelik.art 2.0k puan sordu
0 oy
1 cevap 245 gösterim
245 gösterim
Android projesi kopyaladım bir github dan, kendi localimde çalıştıramadım. Şu hatayı almaktayım. Bilgisi olan var mı? No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. Orginal hata ise; [2017-05-30 14:18:31 - LoginActivity] D:\ ... .xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
30 Mayıs 2017 Java kategorisinde tolgacelik.art 2.0k puan sordu
0 oy
1 cevap 690 gösterim
690 gösterim
Spring kullanrak Rest service ile getUser (userId ile alıyorum) ve getByUserName diye iki methodum var ve userl leri ise api/user/{id} api/user/{userName} şeklinde, ancak ikisini seçmekte kararsız kalıyor sanırım. Bunu nasıl çözerim. @RequestMapping(value = "/user/{userName}", method = ... id) { ............. alınan hata ise; Error: Ambiguous handler methods mapped for HTTP path in spring...
16 Temmuz 2017 Java kategorisinde tolgacelik.art 2.0k puan sordu
0 oy
1 cevap 748 gösterim
748 gösterim
Hibernate kulanarak CrudRepostiory implement ediyor ve native Query yazmak istiyorum. Bu mümkün müdür? Mümkün ise örnek bir syntax verebilir misiniz?
25 Temmuz 2017 Java kategorisinde tolgacelik.art 2.0k puan sordu
0 oy
1 cevap 406 gösterim
406 gösterim
Spring^de hazır olarak gelen CrudRepository hibernate ile veri crud işlemlerini yapıyorum. Ancak standart methodların dışında, custom bir select yazmaya çalışırsak nasıl olur? public interface UserRepositoryCustom extends CrudRepository<User,Long>{ User findByLastName(String lastName); } yapsak yeterli olur mu?
16 Temmuz 2017 Java kategorisinde tolgacelik.art 2.0k puan sordu