2008/12/18 epitka <[email protected]>

>
> What is am after is just a simple way to confim that it either exists
> or not without hydrating entities. So select e.id would do it?


"select e.id ..." return an instance of the id (in your case a string) if
present.


>
> Example api does not provide IncludeProperties just ExcludeProperties.
> Is there a reason other then time?
>
> On Dec 18, 10:41 am, "Fabio Maulo" <[email protected]> wrote:
> > I prefer use DAO/Repository that is the only tier knowing something about
> > persistence.Where I need a specific Exists method based on a NaturalId
> I'm
> > not using Count but only
> > select e.id from .... where .....
> >
> > 2008/12/18 epitka <[email protected]>
> >
> >
> >
> >
> >
> > > Thanks Fabio,
> > > I look into named query, I think I found another thread that talks
> > > about this.  I put this in the "service" rather then "repository". My
> > > repositories only fetch and persist. Anything else like get the total
> > > of something, check this or that go into service classes. Does this
> > > make sense?
> >
> > > On Dec 18, 10:08 am, "Fabio Maulo" <[email protected]> wrote:
> > > > - Create a method in your DAO/Repository named Exists(YourEntity
> example)
> > > -
> > > > In the mapping write a namedQuery named "YourEntity.Exists"
> > > > - the query may look like : select count(*) from YourEntity e where
> > > > e.NaturalIdProperty1 = :pp1 and e.NaturalIdProperty2 = :pp2
> > > > - Implements the Exists method using the named query
> >
> > > > If you don't want use HQL you can use Criteria but, in this case
> where
> > > you
> > > > have a static query, HQL is better candidate.
> >
> > > > 2008/12/18 epitka <[email protected]>
> >
> > > > > Hi,
> > > > > I use surrogate keys on my tables, but some tables have columns
> that
> > > > > are unique. For example one cannot create a project that has the
> same
> > > > > name. So I am wondering what is the best way to query using NH to
> > > > > check if name already exists in the table, so I can make a check
> > > > > rather then catching exception. I do not want to populate the
> entity
> > > > > with that name just return count. Can anybody give example.
> >
> > > > --
> > > > Fabio Maulo
> >
> > --
> > Fabio Maulo
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to