(newbie) Only getting null values back - am I doing this right :)

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 23-Jul-2007 14:34:41   

Hello

Well I'm starting to make some progress with LLBL and getting to grips with it.

However, when I do this:

SitesEntity oSite = new SitesEntity(1);

All the values that come back are null - even though in my Sites table in the database, I do have a PK of 1 and values assigned to it.

What am I doing wrong?

Many thanks

Darren

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 23-Jul-2007 15:32:52   

Hello,

what scenario do you use? What version of llbl do you use? When you define the new entity, all fields are empty and your entity is ready to be filled. To fill the entity, you need to fetch it (using an adapter for the adapter scenario for example).

daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 23-Jul-2007 15:38:28   

Hi jbb

I am using version 2.0.0.0 Final and I'm on the Adapter model - though I don't really know what benefits or differences that gives me over the SelfServicing model.

With regards to filling the entity - do you have a snippett of code I could look at please?

I'm just reading through the manual now to get a bit more information on how to best use LLBL.

Many thanks

Darren

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 23-Jul-2007 15:45:53   

Hi,

in the manual you can find the solution in : Generated code - Using the entity classes, Adapter.

So you need to create an adapter.

DataAccessAdapter adapter = new DataAccessAdapter();

And then fetch your entity

SitesEntity oSite = new SitesEntity(1);
adapter.fetchEntity(oSite);
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 23-Jul-2007 15:48:27   

That is a great help - thanks very much!

Could you briefly explain in idiot friendly terms the difference between the two template groups please?

Best regards

Darren

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 23-Jul-2007 16:07:14   

When to use which template group? Both template groups offer a wide set of functionality, but do that in a different way. This difference makes it important for you to know when to pick which template group for a given project. Below are two short lists which sum up some reasons for choosing each template group and which will help you with the decision which template group to take.

When to use SelfServicing

-When the project targets a single database type. -When you are not using a distributed scenario like remoting or webservices. -When you need navigation through your object model in a databinding scenario and you -want to load the data using lazy loading. -When you don't need to extend the framework. -When you like to have the persistence logic into the entity classes. -When you do not require fine grained database access control, like targeting per call another database.

When to use Adapter

-When the project targets multiple database types or would be able to do that in the future. -When you are using a distributed scenario like remoting or webservices. -When you don't need lazy loading scenarios in relation traversals. You can still navigate relations but you have to fetch the data up-front. -When you need to extend the framework with derived classes. -When you like to see persistence logic as a 'service', which is offered by an external object (broker, adapter). -When you require fine grained database access control.

So as you can read, it really depend on what you need to do in your project(multiple database type, webservices,lazy loading ..) First of all, you need to define what you want to do with your data. You can find all the text in the manual, section: Concepts - Templates and Template groups

daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 23-Jul-2007 16:43:42   

Hi jbb

Thanks - it has been a great help - I am reading through the concepts section of the manual and the lightbulb is starting to glow above my head!

I was just a bit overwhelmed by 400 pages but I'm getting there now!

Many thanks

Darren

simple_smile