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

Exception in thread java.lang.ArrayIndexOutOfBoundsException: 5
Extracting Phone Number with Call Text from String using Reg exp
Eclipse E4: E4 Dev Tools Official Download Site. And why Aren't They Included?
Need to make a variable within an action listener public
QueryDSL sorting not working with Spring Data
How to Sort a HashTable [duplicate]
String Pool - String Object - Garbage Collection
How to create framework.odex in android
error in android programming [closed]
How do I create a Stream of regex matches?
JavaFX center an image doesn't work
Calling super method from within an anonymous inner class inside the overridden method
Java SWT ProgressMonitorDialog with UI Thread
Reorder columns in a random order
Load test specific properties when run from integration test or default .yml
Spring Boot any way to define a JTA resource?

Categories

HOME
variables
clips
vbscript
atom-editor
blogger
gremlin
single-sign-on
path-finding
onedrive
vmware
relay
youtube-dl
routes
v8
webrequest
amazon-cloudformation
ssl-client-authentication
nstableview
google-apps-marketplace
django-simple-history
opentracing
systemc
accessor
extjs5
bootstrap-tour
restful-authentication
crosstab
fifo
c++-amp
sql-server-2012-express
preg-match
fabric8
directx-10
key-value-observing
.net-4.0
titanium-mobile
webtest
framemaker
mapdb
serverside-rendering
withings
android-fingerprint-api
broadcastreceiver
hp-ux
pdf-reactor
quadratic-programming
password-encryption
skeleton-css-boilerplate
rails-routing
worksheet
pebble-watch
jxcore
magma
lift-json
sybase-asa
namecoin
flutterwave
spring-cache
synchronous
time-and-attendance
visual-c++-2008
mikroc
django-debug-toolbar
bluemix-app-scan
apachebench
browser-link
iad
jms2
google-places
marching-cubes
tmuxinator
varargs
map-projections
fluid-dynamics
angular-local-storage
clipperlib
javax.mail
offloading
pick
android-nested-fragment
device-manager
neolane
zend-route
mesa
seaside
mcts
page-layout
farseer
web2py-modules
mylyn
hungarian-algorithm
comaddin
distutils
funscript
dsn
onsubmit
ticoredatasync
bubble-chart
gwt-ext
vdsp
ecl
winbugs14
pyinotify
gamequery
wise
suppress
getresponsestream
lzh

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