zwwcn

Just another WordPress.com site

Monthly Archives: February 2012

“The converter works with any managed entity”.

if we have to include unmanaged entity into selectone menu, we will need manually create select items.

Jsf page:

<h:selectOneMenu id=”contact” required=”true” styleClass=”input”  value=”#{jobAddress.contact}” >
<f:selectItems value=”#{newCustomerController.newCustomerContacts}”/>
</h:selectOneMenu>

java code to generate select items:

for(Contact contact : selectedCustomer.getContacts()) {
SelectItem item = new SelectItem();
item.setValue(contact);
item.setLabel(contact.getFirstName() + ” ” + contact.getLastName());
newCustomerContacts.add(item);
}

Property not found on type org.hibernate.collection.PersistentSet

JSF doesn’t support dataTable backed by Sets (Seam does if you use @DataModel).

tempary table

A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.)

 

CREATE TEMPORARY TABLE TMP_BILL_ADDRESS(ADDRESS_ID bigint);

INSERT INTO TMP_BILL_ADDRESS(ADDRESS_ID)
SELECT a.OBJECT_ID FROM OP_ADDRESS a;

DROP TABLE TMP_BILL_ADDRESS;

 

update , delete and left join

UPDATE OP_CONTACT c
LEFT JOIN OP_CONTACTTYPE ct ON ct.CONTACT_ID = c.OBJECT_ID
LEFT JOIN OP_CUSTOMER_CONTACT_XREF ref ON ref.CONTACT_TYPE_ID = ct.OBJECT_ID
SET c.IS_BILLING = (ct.TYPE = “BillContact”)
WHERE ref.CUSTOMER_ID IS NOT NULL AND ct.TYPE IN (“ShipContact”,”OtherContact”,”BillContact”);

 

DELETE  ad

FROM ADDRESS ad

LEFT JOIN CUSTOMER c ON c.ADDRESS_ID = ad.OBJECT_ID;

 

Temporary tables

Temporary Tables, or temp tables for short, allow you to create a short-term storage place within the database for a set of data that you need to use several times in a single series of operations. Temp tables come into play when it isn’t possible to retrieve all the data that you require using one SELECT statement or when you want to work with subsets of the same, larger resultset over several successive operations. Temp tables are supported in MySQL 3.23 and later.

Quote from http://www.linuxplanet.com/linuxplanet/tutorials/6889/1

e.g:

CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl;

INSERT  INTO newtable 
SELECT title, hits, userid 
FROM oldtable WHERE title <>  '' 
ORDER  BY title;

Validation Error: Value is not valid

this problem happens when you dynamically change the list for a selectonemenu or picklist, when you submit the form the selectitems are different from they were when the page is rendered.

solution: 1 in seam , we just need to make sure it’s  in a long running conversation. it won’t work if it’s event scope.

2 overrides equals  and hashcode method