moretti.fabio

1

votes
0

answer
143

views

JDBC treat warnings as error on data truncation

I have a MySQL table with three fields: fname varchar(20) ftype varchar(10) value varchar(30) as you can see 'value' is a varchar, but I use it to store differente kind of value (entered by users), so I can do: UPDATE table SET value = 1 + value WHERE ftype='COUNTER'; it works as intended,...
moretti.fabio
1

votes
3

answer
677

views

Proof of concept: how I can create a generic comparator method with reflection?

I hava a lot of classes like this: Class Person { protected String name; protected String surname; ...getters and setters... } I'd like to order a Collection of Person by name or by surname. Actually I'm simply doing this: Collections.sort(listofpersons, new Comparator(){ @Override public int compa...
moretti.fabio
1

votes
1

answer
2.6k

views

Reading JSON to map with JAX-RS

I'm writing a Java EE REST application (it runs under Glassfish 4.1) and I'm having problems reading a simple key-value JSON list. I'm trying to produce and consume a JSON using a POJO class, producing works fine, but consuming is not working. Let's get to the code. The POJO class I use for produce...
moretti.fabio
1

votes
1

answer
492

views

Why I can't inject multiple instances of a bean?

I have two beans: one manage a single stock, other manage the movements between two stocks. So, in the MovStock bean I have: @EJB private Stock stock1; @EJB private Stock stock2; [...] public void setStocks(int idStock1, int idStock2) { stock1.loadStock(idStock1); stock2.loadStock(idStock2); } somew...
moretti.fabio
1

votes
1

answer
80

views

About generics and lists in java

I've this simple interface: public interface Transportable { public T getTransport(); } and a lot of classes that provide implementation, ie: class A implements Transportable { public ATransport getTransport() { ATransport at=new ATransport(); [...] return at; } } class B implements Transportable {...
moretti.fabio
1

votes
2

answer
411

views

Inject of remote EJB interface into external module

I have an EAR application with three modules: beans are in 'app-ejb' module remote interfaces are in 'app-remote' web services are in 'app-war' app-ejb and app-war use app-remote as library. all are packaged in 'app.ear'. This is working fine, but now I have to use the same beans outside the EAR ap...
moretti.fabio
1

votes
2

answer
3.1k

views

kendo-ui autocomplete extend

I'm trying to extend the kendo-ui autocomplete control: I want the search start when te user hit enter, so basically I've to check the user input on keydown event. I've tried to catch the keydown event with this code: (function($) { ui = kendo.ui, Widget = ui.Widget var ClienteText = ui.AutoComplete...
moretti.fabio
1

votes
1

answer
2.2k

views

Complex criteria query: using JPA instead of NativeQuery

I've in my Java EE project this NativeQuery for MySQL: SELECT *, ROUND((price_2-price_1)*100/price_1,2) AS varprice_1, ROUND((quantity_2-quantity_1)*100/quantity_1,2) AS varcant_1, ROUND((price_3-price_2)*100/price_2,2) AS varprice_2, ROUND((quantity_3-quantity_2)*100/quantity_2,2) AS varcant_2, 1...
moretti.fabio
6

votes
1

answer
1.2k

views

using f:viewParam with required attribute and commands

I want to share my experience using primefaces, f:viewParam and p:commandButton, and ask a few questions.Take a look at this page: The backing bean have a 'myMethod()' method that does nothing. When you enter the page it expects the 'id_file' parameter and put it in the idFile property of the backin...
moretti.fabio
3

votes
1

answer
2.8k

views

JPA: merge and persist,catch ConstraintViolationException

Hi, I have a doubt how to catch a ConstraintViolationException during merge. I have my JPALogic class and I want to catch the exception to write down more informations, this code works perfectly, throwing the GenericSaveException: try { em.persist(o); } catch (ConstraintViolationException e) { Syste...
moretti.fabio
4

votes
1

answer
1.2k

views

JPA does not delete database row

I'm facing a delete problem with JPA, and this is my code: public deleteLine(int idLine) { Line line = em.find(Line.class,idLine); Header header = line.getHeader(); this.deleteLine(header,line); } public boolean deleteLine(Header header, Line line) { try { line.setIdArticle(null); line.setDetail(DEL...
moretti.fabio
3

votes
1

answer
133

views

Local variables vs setter using generics in functions

I've an interface ITransportable that force the classes who implements it to have two methods, one for produce a object based on 'this', and one to load 'this' from a object. In fact I'm using 'transports' object to hide the underlying classes to the user, so every class that is 'transportable', i...
moretti.fabio
3

votes
1

answer
341

views

Cannot put EJB in a separate jar

I have an EJB with some JPA logic that I use in my java EE projects. Instead of copying the class in every project I'm trying to put it in a separate jar, so I have this structure: Java EE project with EJB and WAR projects in it JPALogic: JAR project with JPALogic class in it RemoteServices: JAR pro...
moretti.fabio
2

votes
3

answer
487

views

Java: identical Objects, how to avoid duplicated code

I've a proyect that call various webservices using an external library. This library give me objects like this: public static class ObjA { @XmlElement(name = 'counter', required = true) protected BigInteger counter; @XmlElement(name = 'data', required = true) protected String data; [...] } and this:...
moretti.fabio