java


How to use Transformers.aliasToBean(Class) with ArrayList?


I am ussing hibernate and I'm trying to make something.
This is my class:
public class TeamLeaderJOBscalar {
public ArrayList<Integer> mySubordinates;
public TeamLeaderJOBscalar(){
}
public ArrayList<Integer> getMySubordinates() {
return mySubordinates;
}
public void setMySubordinates(ArrayList<Integer> mySubordinates) {
this.mySubordinates = mySubordinates;
}
}
and I want to use it here:
int idEmp = 22;
String myTeam = "select emp.id_emp as mySubordinates from employee emp"
+ "inner join lead on lead.lead= emp.id_emp "
+ "where lead.leadBoss= :idGBSUser ";
Query simpleSQL = session.createSQLQuery(myTeam)
.addScalar("mySubordinates", Hibernate.OBJECT)
.setParameter("idGBSUser", idEmp)
.setResultTransformer(Transformers.aliasToBean(TeamLeaderJOBscalar.class));
#SuppressWarnings("unchecked")
List<TeamLeaderJOBscalar> rezQuery = simpleSQL.list();
ArrayList<Integer> myTeamForTL = new ArrayList<Integer>();
for (TeamLeaderJOBscalar item : rezQuery) {
myTeamForTL = item.getMySubordinates();
}
I don't know what to use in this line:
.addScalar("mySubordinates",Hibernate.OBJECT).
I want to print the result in that foreach. Is this working on collections too?...I mean, I recently used something like this, but in bean classes I had simple attributes like string, int and I've used: .addScalar("name", Hibernate.STRING), etc. But now, I want a list. The result of that query returns me more than one record (it returns some ids), and i want to put them in a list...so I can send it to another class.

Related Links

I want to display the element in an arraylist, not the hashcode
How to create a email link in POI Word Format
private static method in class pros and cons?
Check whether web page exist on the web or not
How do I convert byte[] to Bitmap?
can xsd definition of type reference the xml file itself?
Where to place i18n key strings in Java
How to print XML Schema
Stand Alone Java Compiler?
How to pass List in sql query
I'm trying to use Java's HttpURLConnection to do a “conditional get”, but I never get a 304 status code
how do I test app exit with jemmy
java.lang.NoClassDefFoundError with external jars in java applet
Mockito + Spy: How to gather return values
Where to write and store mongoDB map/reduce functions in java project
Indenting Java source files using Eclipse

Categories

HOME
vim
proxy
grep
microservices
jsrender
sqlite3
packages
webpack-2
azure-storage-tables
append
facebook-messenger-bot
applepay
elasticsearch-hadoop
jplayer
vb.net-2010
libtiff
aurigma
invantive-sql
code-review
scichart
predix
one-hot-encoding
sox
accessor
fish
replaceall
facebook-apps
nat
microsoft-chart-controls
media-queries
phonegap
xquery-3.0
scorm2004
y86
mapbox-gl
html5-fullscreen
plsql-psp
jquery-bootgrid
jna
lumberjack
greenrobot-eventbus
broadcastreceiver
import-from-excel
eclipse-gef
skeleton-css-boilerplate
scrollable
osx-mavericks
react-scripts
jlink
return-value
pg-dump
google-perftools
media-player
pillow
imanage
redundancy
medium.com
instant
trash
gridview-sorting
multiple-regression
sigabrt
essence
master-slave
design-by-contract
itextpdf
jfugue
retina
pundit
wyam
embedded-code
0xdbe
deis
myo
event-bubbling
iiviewdeckcontroller
apache-commons-net
c++03
cdt
castle
yorick
dexterity
sitemesh
smtp-auth
chuck
dice
viewswitcher
netbeans-6.9
eclipse-templates
doh
subgurim-maps
infobox
xmlspy
xtype
site.master
yslow
forums
dbal
rescale
geneva-server
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App